Skip to content

Commit

Permalink
PRINT skip broken images and just log warning
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreKelling committed Feb 14, 2024
1 parent 7ecedaa commit d32cb25
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 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",
"version": "1.0.7",
"version": "1.0.8",
"main": "src/app.js",
"author": "André Kelling",
"description": "Dymo Label PDF printing.",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jspdf-template-labelprint",
"version": "1.0.7",
"version": "1.0.8",
"main": "src/app.js",
"author": "André Kelling",
"description": "Dymo Label PDF template",
Expand Down
8 changes: 5 additions & 3 deletions src/print/partials/logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ export default (doc, logo) => {
const maxHeightLogoInPx = Math.round((maxHeightLogo -7) * mmDpiFactor); // minus 6mm, for spacing to top and 5 for better spacing and calculation at all
const pageCenterX = pageWidth / 2;

const imageProps = doc.getImageProperties(logo);
let imageProps;

if (imageProps.fileType === 'UNKNOWN') {
console.warn('UNKNOWN image fileType for logo')
try {
imageProps = doc.getImageProperties(logo);
} catch (error) {
console.warn('Error getting image properties for logo', error);
return;
}

Expand Down
8 changes: 5 additions & 3 deletions src/print/partials/qr-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export default (doc, qrCode, pageWidth) => {
const maxHeightInPx = qrCodeDimension;
const pageCenterX = pageWidth / 2;

const imageProps = doc.getImageProperties(qrCode);
let imageProps;

if (imageProps.fileType === 'UNKNOWN') {
console.warn('UNKNOWN image fileType for qrCode')
try {
imageProps = doc.getImageProperties(qrCode);
} catch (error) {
console.warn('Error getting image properties for qrCode', error);
return;
}

Expand Down

0 comments on commit d32cb25

Please sign in to comment.