Skip to content

Commit

Permalink
Merge pull request #14994 from Snuffleupagus/parseJbig2-conditional
Browse files Browse the repository at this point in the history
Conditionally bundle `gulp image_decoders`-specific code in `src/core/jbig2.js` (PR 9729 follow-up)
  • Loading branch information
timvandermeij authored Jun 6, 2022
2 parents 1816b5e + e82ad79 commit 135b9fb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/jbig2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1473,8 +1473,7 @@ function processSegment(segment, visitor) {
break;
default:
throw new Jbig2Error(
`segment type ${header.typeName}(${header.type})` +
" is not implemented"
`segment type ${header.typeName}(${header.type}) is not implemented`
);
}
const callbackName = "on" + header.typeName;
Expand All @@ -1500,6 +1499,9 @@ function parseJbig2Chunks(chunks) {
}

function parseJbig2(data) {
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("IMAGE_DECODERS")) {
throw new Error("Not implemented: parseJbig2");
}
const end = data.length;
let position = 0;

Expand Down Expand Up @@ -2560,6 +2562,9 @@ class Jbig2Image {
}

parse(data) {
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("IMAGE_DECODERS")) {
throw new Error("Not implemented: Jbig2Image.parse");
}
const { imgData, width, height } = parseJbig2(data);
this.width = width;
this.height = height;
Expand Down

0 comments on commit 135b9fb

Please sign in to comment.