Skip to content

Commit

Permalink
minor improvements, v1.0.1
Browse files Browse the repository at this point in the history
EliDeh committed Aug 10, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 925ae9f commit b3976ef
Showing 6 changed files with 63 additions and 65 deletions.
35 changes: 20 additions & 15 deletions signaturenDruck/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
# electron-quick-start
# SignaturenDruck

**Clone and run for a quick way to see Electron in action.**

This is a minimal Electron application based on the [Quick Start Guide](https://electronjs.org/docs/tutorial/quick-start) within the Electron documentation.
This is a Electron application to print shelfmarks read from a `.dnl`-file. It displays shelfmarks from the file in a table like structure. You can then select and print the shelfmarks you like.

**Use this app along with the [Electron API Demos](https://electronjs.org/#get-started) app for API code examples to help you get started.**

A basic Electron application needs just these files:
The printing process creates two `.pdf`-files (each for one size) and proceeds to print them silently via Foxit Reader.

- `package.json` - Points to the app's main file and lists its details and dependencies.
- `main.js` - Starts the app and creates a browser window to render HTML. This is the app's **main process**.
- `index.html` - A web page to render. This is the app's **renderer process**.

You can learn more about each of these components within the [Quick Start Guide](https://electronjs.org/docs/tutorial/quick-start).

## To Use
To use this application you'll need to install [Foxit Reader v6.2.3.0815](http://cdn01.foxitsoftware.com/pub/foxit/reader/desktop/win/6.x/6.2/enu/FoxitReader623.815_enu_Setup.exe) on your computer.

To clone and run this repository you'll need [Git](https://git-scm.com) and [Node.js](https://nodejs.org/en/download/) (which comes with [npm](http://npmjs.com)) installed on your computer. From your command line:

```bash
# Clone this repository
git clone https://github.com/electron/electron-quick-start
git clone https://github.com/EliDeh/abschlussProjekt
# Go into the repository
cd electron-quick-start
cd abschlussProjekt
# Install dependencies
npm install
# Run the app
npm start
```

Note: If you're using Linux Bash for Windows, [see this guide](https://www.howtogeek.com/261575/how-to-run-graphical-linux-desktop-applications-from-windows-10s-bash-shell/) or use `node` from the command prompt.
**Clone and run for a quick way to see Electron in action.**

This is a minimal Electron application based on the [Quick Start Guide](https://electronjs.org/docs/tutorial/quick-start) within the Electron documentation.

**Use this app along with the [Electron API Demos](https://electronjs.org/#get-started) app for API code examples to help you get started.**

A basic Electron application needs just these files:

- `package.json` - Points to the app's main file and lists its details and dependencies.
- `main.js` - Starts the app and creates a browser window to render HTML. This is the app's **main process**.
- `index.html` - A web page to render. This is the app's **renderer process**.

You can learn more about each of these components within the [Quick Start Guide](https://electronjs.org/docs/tutorial/quick-start).


## Resources for Learning Electron

38 changes: 38 additions & 0 deletions signaturenDruck/css/modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}

/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}

.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
41 changes: 1 addition & 40 deletions signaturenDruck/index.html
Original file line number Diff line number Diff line change
@@ -6,46 +6,7 @@
<title>Signaturendruck</title>
<link rel="stylesheet" type="text/css" href="./css/index.css">
<link rel="stylesheet" type="text/css" href="C:/Export/user.css">
<style>
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}

/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}

.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
</style>
<link rel="stylesheet" type="text/css" href="./css/modal.css">
</head>

<body>
11 changes: 2 additions & 9 deletions signaturenDruck/main.js
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ function checkConfig () {
createConfig()
}
}

// checks if the tmp-dir exists, else creates it
function checkTmpDir () {
try {
fs.mkdirSync('./tmp')
@@ -151,6 +151,7 @@ ipc.on('close', function (event) {
app.quit()
})

// listens on printed, invokes then printMsg via ipc
ipc.on('printed', function (event) {
mainWindow.webContents.send('printMsg', true)
})
@@ -166,20 +167,13 @@ function printBig (data) {
}))
winBig.once('ready-to-show', () => {
winBig.webContents.send('toPrint', data)
// generated pdf prints fine if printed manually using Adobe Reader
// Tested with Adobe Acrobat X Pro
// winBig.webContents.printToPDF({marginsType: 2, landscape: false, pageSize: { width: 48920, height: 99970 }}, (error, data) => {

// generates a pdf file which is then printed silently via Foxit Reader v6.2.3.0815
// // since SumatraPDF v3.1.2 can't handle pdf pages where width > height we have to modify the settings accordingly
// // there is already a fix in sight which should roll out with the next official SumatraPDF release
// winBig.webContents.printToPDF({marginsType: 2, landscape: false, pageSize: { width: 99970, height: 110000 }}, (error, data) => {
winBig.webContents.printToPDF({marginsType: 2, landscape: true, pageSize: { width: config.store.big.label.height, height: config.store.big.label.width }}, (error, data) => {
if (error) throw error
fs.writeFile('./tmp/' + config.store.big.pdfName, data, (error) => {
if (error) throw error
console.log('Wrote ' + config.store.big.pdfName + ' successfully')

if (!config.store.devMode) {
// printing with Foxit Reader 6.2.3.0815 via node-cmd
cmd.get(
@@ -215,7 +209,6 @@ function printSmall (data) {
winSmall.once('ready-to-show', () => {
winSmall.webContents.send('toPrint', data)
winSmall.webContents.printToPDF({marginsType: 2, landscape: true, pageSize: { width: config.store.small.label.height, height: config.store.small.label.width }}, (error, data) => {
// winSmall.webContents.printToPDF({marginsType: 2, landscape: false, pageSize: { width: 74500, height: 80000 }}, (error, data) => {
if (error) throw error
fs.writeFile('./tmp/' + config.store.small.pdfName, data, (error) => {
if (error) throw error
2 changes: 1 addition & 1 deletion signaturenDruck/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SignaturenDruck",
"version": "1.0.0",
"version": "1.0.1",
"description": "SignaturenDruck der ThULB",
"main": "main.js",
"scripts": {
1 change: 1 addition & 0 deletions signaturenDruck/renderer.js
Original file line number Diff line number Diff line change
@@ -416,6 +416,7 @@ function printButton () {
ipc.send('print', data)
}

// listens on printMsg, invokes the modal
ipc.on('printMsg', function (event) {
document.getElementById('myModal').style.display = 'block'
})

0 comments on commit b3976ef

Please sign in to comment.