Skip to content

Commit

Permalink
refactor: clean up examples
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Nov 9, 2023
1 parent 8e02f41 commit b865b59
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/browser-bundling-with-webpack/src/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ const pdf = new PDFDocument();
const qrBill = new SwissQRBill(data);

qrBill.attachTo(pdf);
pdf.pipe(stream);

stream.on("finish", () => {
window.location.href = stream.toBlobURL("application/pdf");
console.log("PDF has been successfully created.");
});

pdf.pipe(stream);
pdf.end();
11 changes: 3 additions & 8 deletions examples/browser-pre-built-bundle/src/pdf.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { data } from "./data.js";


const width = SwissQRBill.utils.mm2pt(210);
const height = SwissQRBill.utils.mm2pt(105);

const pdf = new PDFDocument({ size: [width, height] });
const stream = pdf.pipe(blobStream());
const stream = new BlobStream();
const pdf = new PDFDocument({ size: "A4" });
const qrBill = new SwissQRBill.pdf.SwissQRBill(data);

qrBill.attachTo(pdf);
pdf.end();

stream.on("finish", () => {
window.location.href = stream.toBlobURL("application/pdf");
});

qrBill.attachTo(pdf);
pdf.pipe(stream);
pdf.end();
6 changes: 3 additions & 3 deletions examples/node-cjs-javascript/src/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const data = require("./data");


const stream = createWriteStream("./output/swissqrbill.pdf");
const pdf = new PDFDocument({ size: "A4" });
const pdf = new PDFDocument();
const qrBill = new SwissQRBill(data);

pdf.pipe(stream);

qrBill.attachTo(pdf);

pdf.pipe(stream);
pdf.end();
1 change: 1 addition & 0 deletions examples/node-cjs-javascript/src/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ const data = require("./data.js");


const qrBill = new SwissQRBill(data);

writeFileSync("./output/swissqrbill.svg", qrBill.toString());
6 changes: 3 additions & 3 deletions examples/node-esm-javascript/src/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { data } from "./data.js";


const stream = createWriteStream("./output/swissqrbill.pdf");
const pdf = new PDFDocument({ size: "A4" });
const pdf = new PDFDocument();
const qrBill = new SwissQRBill(data);

pdf.pipe(stream);

qrBill.attachTo(pdf);

pdf.pipe(stream);
pdf.end();

0 comments on commit b865b59

Please sign in to comment.