Skip to content

Commit

Permalink
SAVE add optional param for blob file output
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreKelling committed Mar 14, 2024
1 parent 111011f commit 2cd7178
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jspdf-product-label-54x70",
"version": "1.2.10",
"version": "1.3.0",
"main": "src/app.js",
"author": "André Kelling",
"description": "Dymo Label PDF printing 54 x 70mm.",
Expand Down
2 changes: 1 addition & 1 deletion src/print/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ declare interface PrintData {
productId?: string
}

export declare function printPDF(printData: PrintData[]): JsPDF;
export declare function printPDF(printData: PrintData[], asBlob?: boolean): JsPDF;
5 changes: 3 additions & 2 deletions src/print/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import assembleFileName from "./utils/file-name.js";

/**
* @param {PrintData[]} printDataArr
* @param {boolean} asBlob if true, returns the pdf as a blob
* @returns {JsPDF}
*/
export default (printDataArr) => {
export default (printDataArr, asBlob = false) => {
const options = {
orientation: 'p',
format: [54, 70]
Expand Down Expand Up @@ -52,5 +53,5 @@ export default (printDataArr) => {
// <><>><><>><>><><><><><>>><><<><><><><>
const fileName = assembleFileName(printDataArr.length, printDataArr[0]);

return doc.save(fileName + ".pdf");
return asBlob ? doc.output('blob') : doc.save(fileName + ".pdf");
}

0 comments on commit 2cd7178

Please sign in to comment.