Formatting
This commit is contained in:
parent
004b118488
commit
6e5e513f64
7
.editorconfig
Normal file
7
.editorconfig
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
root=true
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 3
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
45
index.js
45
index.js
@ -13,8 +13,8 @@ function randomId(length) {
|
|||||||
//Generating random preset, to identify possible doubles
|
//Generating random preset, to identify possible doubles
|
||||||
const preset = randomId(3);
|
const preset = randomId(3);
|
||||||
|
|
||||||
console.log("The radnom preset for this set is:", preset);
|
console.log("The random preset for this set is:", preset);
|
||||||
console.log("Make shure this was not used before and if so, retry")
|
console.log("Make sure this was not used before and if so, retry");
|
||||||
var etk = {};
|
var etk = {};
|
||||||
|
|
||||||
for (var i = 0; i < 12 * 100; i++) {
|
for (var i = 0; i < 12 * 100; i++) {
|
||||||
@ -25,12 +25,11 @@ for (var i = 0; i < 12 * 100; i++) {
|
|||||||
|
|
||||||
var ets = Object.keys(etk);
|
var ets = Object.keys(etk);
|
||||||
|
|
||||||
const bluebird = require("bluebird");
|
|
||||||
const PDFDocument = require("pdfkit");
|
const PDFDocument = require("pdfkit");
|
||||||
const doc = new PDFDocument({ size: "A4", autoFirstPage: false });
|
const doc = new PDFDocument({ size: "A4", autoFirstPage: false });
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
//const barcode = require("barcode");
|
//const barcode = require("barcode");
|
||||||
const bwipjs = require('bwip-js');
|
const bwipjs = require("bwip-js");
|
||||||
const ewidth = 277;
|
const ewidth = 277;
|
||||||
const eheight = 119;
|
const eheight = 119;
|
||||||
const mgap = 8.49;
|
const mgap = 8.49;
|
||||||
@ -65,7 +64,7 @@ function print(xo, yo, bc) {
|
|||||||
doc.moveTo(xo + (ewidth / 4) * 2.4 + 5, h).lineTo(xo + ewidth - 10, h);
|
doc.moveTo(xo + (ewidth / 4) * 2.4 + 5, h).lineTo(xo + ewidth - 10, h);
|
||||||
doc.stroke();
|
doc.stroke();
|
||||||
//Sid Field:
|
//Sid Field:
|
||||||
var h = yo + (eheight / 4) + 10;
|
var h = yo + eheight / 4 + 10;
|
||||||
|
|
||||||
doc.text("SchülerId", xo + (ewidth / 4) * 2.4 + 5, h + 6);
|
doc.text("SchülerId", xo + (ewidth / 4) * 2.4 + 5, h + 6);
|
||||||
doc.moveTo(xo + (ewidth / 4) * 2.4 + 5, h).lineTo(xo + ewidth - 10, h);
|
doc.moveTo(xo + (ewidth / 4) * 2.4 + 5, h).lineTo(xo + ewidth - 10, h);
|
||||||
@ -75,29 +74,33 @@ function print(xo, yo, bc) {
|
|||||||
var imagewidth = (ewidth / 4) * 2.2;
|
var imagewidth = (ewidth / 4) * 2.2;
|
||||||
var imageheight = 20;
|
var imageheight = 20;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
bwipjs.toBuffer({
|
bwipjs.toBuffer(
|
||||||
bcid: "code128",
|
{
|
||||||
text: bc,
|
bcid: "code128",
|
||||||
scale: 1,
|
text: bc,
|
||||||
height: imageheight,
|
scale: 1,
|
||||||
width: imagewidth,
|
height: imageheight,
|
||||||
includetext: true,
|
width: imagewidth,
|
||||||
textxalign: "center",
|
includetext: true,
|
||||||
textsize: 15
|
textxalign: "center",
|
||||||
}, (err, png) => {
|
textsize: 15,
|
||||||
if (err) return console.log(err);
|
},
|
||||||
doc.image(png, xo + 5, yo + 5, { height: 50, width: imagewidth });
|
(err, png) => {
|
||||||
resolve();
|
if (err) return console.log(err);
|
||||||
});
|
doc.image(png, xo + 5, yo + 5, { height: 50, width: imagewidth });
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function page(items, callback, index) { //bekommt ein array mit 12 ids
|
function page(items, callback, index) {
|
||||||
|
//bekommt ein array mit 12 ids
|
||||||
doc.addPage({ margin: 0 });
|
doc.addPage({ margin: 0 });
|
||||||
var j = 0;
|
var j = 0;
|
||||||
var proms = [];
|
var proms = [];
|
||||||
for (var i = 0; i < 6; i++) {
|
for (var i = 0; i < 6; i++) {
|
||||||
if (j >= items.length) break;;
|
if (j >= items.length) break;
|
||||||
proms.push(print(14.15, 62.24 + i * eheight, items[j]));
|
proms.push(print(14.15, 62.24 + i * eheight, items[j]));
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
51
students.js
51
students.js
@ -1,16 +1,16 @@
|
|||||||
var PDFDocument = require("pdfkit");
|
var PDFDocument = require("pdfkit");
|
||||||
var doc = new PDFDocument({ size: "A4", autoFirstPage: false });
|
var doc = new PDFDocument({ size: "A4", autoFirstPage: false });
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var bluebird = require("bluebird");
|
var ets = [];
|
||||||
var ets = []
|
|
||||||
var height = 841.89;
|
var height = 841.89;
|
||||||
var width = 595.28;
|
var width = 595.28;
|
||||||
for (var i = 2000; i < 4 * 100 + 2000; i++) {
|
const offset = 4000;
|
||||||
|
for (var i = offset; i < 4 * 100 + offset; i++) {
|
||||||
ets.push(i.toString());
|
ets.push(i.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
//const barcode = require("barcode");
|
//const barcode = require("barcode");
|
||||||
var bwipjs = require('bwip-js');
|
var bwipjs = require("bwip-js");
|
||||||
const margin = 40;
|
const margin = 40;
|
||||||
|
|
||||||
//A4: [595.28, 841.89],
|
//A4: [595.28, 841.89],
|
||||||
@ -20,7 +20,11 @@ function print(xo, yo, bc) {
|
|||||||
xo = xo + 40;
|
xo = xo + 40;
|
||||||
yo = yo + 40;
|
yo = yo + 40;
|
||||||
doc.fontSize(14);
|
doc.fontSize(14);
|
||||||
doc.text("Bitte alle Felder leserlich ausfüllen. \nDie Schüler-ID bitte auf \nALLE Bücher schreiben!!", xo, yo);
|
doc.text(
|
||||||
|
"Bitte alle Felder leserlich ausfüllen. \nDie Nummer unten bitte auf ALLE \nBücher schreiben!!",
|
||||||
|
xo,
|
||||||
|
yo
|
||||||
|
);
|
||||||
doc.fontSize(16);
|
doc.fontSize(16);
|
||||||
yo += 45;
|
yo += 45;
|
||||||
|
|
||||||
@ -57,24 +61,31 @@ function print(xo, yo, bc) {
|
|||||||
var imagewidth = 240;
|
var imagewidth = 240;
|
||||||
var imageheight = 20;
|
var imageheight = 20;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
bwipjs.toBuffer({
|
bwipjs.toBuffer(
|
||||||
bcid: "code128",
|
{
|
||||||
text: bc,
|
bcid: "code128",
|
||||||
scale: 1,
|
text: bc,
|
||||||
height: imageheight,
|
scale: 1,
|
||||||
width: imagewidth,
|
height: imageheight,
|
||||||
includetext: true,
|
width: imagewidth,
|
||||||
textxalign: "center",
|
includetext: true,
|
||||||
textsize: 15
|
textxalign: "center",
|
||||||
}, (err, png) => {
|
textsize: 15,
|
||||||
if (err) return console.log(err);
|
},
|
||||||
doc.image(png, xo + 23 - 40, h + 23, { height: 50, width: imagewidth });
|
(err, png) => {
|
||||||
resolve();
|
if (err) return console.log(err);
|
||||||
});
|
doc.image(png, xo + 23 - 40, h + 23, {
|
||||||
|
height: 50,
|
||||||
|
width: imagewidth,
|
||||||
|
});
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function page(items, callback, index) { //bekommt ein array mit 12 ids
|
function page(items, callback, index) {
|
||||||
|
//bekommt ein array mit 12 ids
|
||||||
doc.addPage({ margin: 0, size: "A4" });
|
doc.addPage({ margin: 0, size: "A4" });
|
||||||
doc.moveTo(width / 2, 0).lineTo(width / 2, height);
|
doc.moveTo(width / 2, 0).lineTo(width / 2, height);
|
||||||
doc.stroke();
|
doc.stroke();
|
||||||
|
Loading…
Reference in New Issue
Block a user