1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #17666 from Snuffleupagus/issue-17665

Skip any whitespace after the first object in linearized PDFs (issue 17665)
This commit is contained in:
Jonas Jenwald 2024-02-13 12:39:36 +01:00 committed by GitHub
commit e60329cea1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 30 additions and 1 deletions

View file

@ -930,7 +930,14 @@ class PDFDocument {
// Find the end of the first object.
stream.reset();
if (find(stream, ENDOBJ_SIGNATURE)) {
startXRef = stream.pos + 6 - stream.start;
stream.skip(6);
let ch = stream.peekByte();
while (isWhiteSpace(ch)) {
stream.pos++;
ch = stream.peekByte();
}
startXRef = stream.pos - stream.start;
}
} else {
// Find `startxref` by checking backwards from the end of the file.

View file

@ -880,6 +880,9 @@ class WorkerMessageHandler {
.ensureXRef("trailer")
.then(trailer => trailer.get("Prev"));
});
handler.on("GetStartXRefPos", function (data) {
return pdfManager.ensureDoc("startXRef");
});
handler.on("GetAnnotArray", function (data) {
return pdfManager.getPage(data.pageIndex).then(function (page) {
return page.annotations.map(a => a.toString());

View file

@ -768,6 +768,9 @@ class PDFDocumentProxy {
Object.defineProperty(this, "getXRefPrevValue", {
value: () => this._transport.getXRefPrevValue(),
});
Object.defineProperty(this, "getStartXRefPos", {
value: () => this._transport.getStartXRefPos(),
});
Object.defineProperty(this, "getAnnotArray", {
value: pageIndex => this._transport.getAnnotArray(pageIndex),
});
@ -2349,6 +2352,10 @@ class WorkerTransport {
value: () =>
this.messageHandler.sendWithPromise("GetXRefPrevValue", null),
});
Object.defineProperty(this, "getStartXRefPos", {
value: () =>
this.messageHandler.sendWithPromise("GetStartXRefPos", null),
});
Object.defineProperty(this, "getAnnotArray", {
value: pageIndex =>
this.messageHandler.sendWithPromise("GetAnnotArray", { pageIndex }),