From b1ed459443f05169b54bbdc631a7e2e21545a1e1 Mon Sep 17 00:00:00 2001 From: fixplz Date: Sat, 3 Dec 2011 00:33:00 +0200 Subject: [PATCH] Scan for startxref more than 1024 chars from end #828 --- src/core.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core.js b/src/core.js index 6b7845efd..9c9be9218 100644 --- a/src/core.js +++ b/src/core.js @@ -382,11 +382,15 @@ var PDFDocModel = (function pdfDoc() { startXRef = stream.pos + 6; } else { // Find startxref at the end of the file. - var start = stream.end - 1024; - if (start < 0) - start = 0; - stream.pos = start; - if (find(stream, 'startxref', 1024, true)) { + var found = false, pos = stream.end; + while(!found && pos > 0) { + pos -= 1024; + if (pos < 0) + pos = 0; + stream.pos = pos; + found = find(stream, 'startxref', 1024, true); + } + if (found) { stream.skip(9); var ch; do {