Skip to content

Commit

Permalink
Merge branch 'master' into scratch/fixRectCoordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
modesty authored Jan 3, 2025
2 parents dd05515 + 5cbaa0f commit 01f6b67
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion base/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ var Parser = (function ParserClosure() {
while (stream.pos < stream.end) {
var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
if (scanLength <= 0) break; // no match possible, end of stream or invalid stream
var found = false, i, ii, j;
for (i = 0, j = 0; i < scanLength; i++) {
var b = scanBytes[i];
Expand All @@ -253,7 +254,7 @@ var Parser = (function ParserClosure() {
stream.pos += scanLength;
}
if (!found) {
error('Missing endstream');
error('Missing endstream or invalid stream');
}
length = skipped;

Expand Down
8 changes: 5 additions & 3 deletions base/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current.font = fontObj;
this.current.fontSize = size;

if (fontObj.coded)
return; // we don't need ctx.font for Type3 fonts
if (fontObj.coded) {
warn('Unsupported Type3 font (custom Glyph) - ' + fontRefName);
return; // we don't need ctx.font for Type3 fonts
}

var name = fontObj.loadedName || 'sans-serif';
var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') :
Expand Down Expand Up @@ -1627,7 +1629,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
//MQZ. make sure endGroup is always invoked after beginGroup
if (this.groupLevel == 0)
this.beginGroup(group);

this.groupLevel--;
var groupCtx = this.ctx;
this.ctx = this.groupStack.pop();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"parse-tb": "./bin/pdf2json.js -f ./test/pdf/misc/i242_testingWithTable.pdf -o ./test/target/misc",
"parse-tc": "./bin/pdf2json.js -f ./test/pdf/misc/i293_pdfpac.pdf -o ./test/target/misc",
"parse-rectFix": "./bin/pdf2json.js -f ./test/pdf/misc/pr298_rect_fix_from_upstream.pdf -o ./test/target/misc",
"parse-e": "./bin/pdf2json.js -f ./test/pdf/misc/i373_err_broken.pdf -o ./test/target/misc",
"parse-e": "./bin/pdf2json.js -f ./test/pdf/misc/i306_err_invalid.pdf -o ./test/target/misc",
"build:rollup": "rollup -c ./rollup.config.js",
"build:bundle-pdfjs-base": "node rollup/bundle-pdfjs-base.js",
"build": "npm run build:bundle-pdfjs-base && npm run build:rollup",
Expand Down
Binary file added test/pdf/misc/i306_err_invalid.pdf
Binary file not shown.

0 comments on commit 01f6b67

Please sign in to comment.