Skip to content

Commit 0337090

Browse files
authored
Basic "unknown image format" error pdf generation handling.
1 parent 340de1a commit 0337090

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/worker.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,16 @@ export const generatePDF = async (
7373
imgBlobs.map((b) => readData(b, "dataUrl"))
7474
);
7575

76-
imgDataUrlList.forEach((data) => {
77-
pdf.addPage();
78-
pdf.image(data, {
79-
width,
80-
height,
81-
});
76+
imgDataUrlList.forEach((data, idx) => {
77+
try {
78+
pdf.addPage();
79+
pdf.image(data, {
80+
width,
81+
height,
82+
});
83+
} except (err) {
84+
console.warn(`Skipping image #${idx} due to error: ${err.message}`);
85+
}
8286
});
8387
} else {
8488
// imgType == "svg"

0 commit comments

Comments
 (0)