diff options
author | Albert Astals Cid <aacid@kde.org> | 2012-02-05 23:09:43 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2012-02-05 23:10:16 +0100 |
commit | 9d997e664b8d903a81e5b9c178a014d681faf475 (patch) | |
tree | 9b358546bc774b080ad2bac4f52248ef58797061 | |
parent | 44f40de623e98e626e117b0a955dc4fc58b21790 (diff) |
We have our on new XRef parsing/recovery mode
-rw-r--r-- | ALL_DIFF | 99 |
1 files changed, 0 insertions, 99 deletions
@@ -12,105 +12,6 @@ diff -ru xpdf-3.02/doc/pdftotext.1 xpdf-3.03/doc/pdftotext.1 .B \-raw Keep the text in content stream order. This is a hack which often "undoes" column formatting, etc. Use of raw mode is no longer -diff -ru xpdf-3.02/xpdf/PDFDoc.cc xpdf-3.03/xpdf/PDFDoc.cc ---- xpdf-3.02/xpdf/PDFDoc.cc 2007-02-27 23:05:52.000000000 +0100 -+++ xpdf-3.03/xpdf/PDFDoc.cc 2011-08-15 23:08:53.000000000 +0200 -@@ -183,38 +209,71 @@ - // check header - checkHeader(); - -+ // read the xref and catalog -+ if (!PDFDoc::setup2(ownerPassword, userPassword, gFalse)) { -+ if (errCode == errDamaged || errCode == errBadCatalog) { -+ // try repairing the xref table -+ error(errSyntaxWarning, -1, -+ "PDF file is damaged - attempting to reconstruct xref table..."); -+ if (!PDFDoc::setup2(ownerPassword, userPassword, gTrue)) { -+ return gFalse; -+ } -+ } else { -+ return gFalse; -+ } -+ } -+ -+#ifndef DISABLE_OUTLINE -+ // read outline -+ outline = new Outline(catalog->getOutline(), xref); -+#endif -+ -+ // done -+ return gTrue; -+} -+ -+GBool PDFDoc::setup2(GString *ownerPassword, GString *userPassword, -+ GBool repairXRef) { - // read xref table -- xref = new XRef(str); -+ xref = new XRef(str, repairXRef); - if (!xref->isOk()) { -- error(-1, "Couldn't read xref table"); -+ error(errSyntaxError, -1, "Couldn't read xref table"); - errCode = xref->getErrorCode(); -+ delete xref; -+ xref = NULL; - return gFalse; - } - - // check for encryption - if (!checkEncryption(ownerPassword, userPassword)) { - errCode = errEncrypted; -+ delete xref; -+ xref = NULL; - return gFalse; - } - - // read catalog - catalog = new Catalog(this); - if (!catalog->isOk()) { -- error(-1, "Couldn't read page catalog"); -+ error(errSyntaxError, -1, "Couldn't read page catalog"); - errCode = errBadCatalog; -+ delete catalog; -+ catalog = NULL; -+ delete xref; -+ xref = NULL; - return gFalse; - } - --#ifndef DISABLE_OUTLINE -- // read outline -- outline = new Outline(catalog->getOutline(), xref); --#endif -- -- // done - return gTrue; - } - -diff -ru xpdf-3.02/xpdf/PDFDoc.h xpdf-3.03/xpdf/PDFDoc.h ---- xpdf-3.02/xpdf/PDFDoc.h 2007-02-27 23:05:52.000000000 +0100 -+++ xpdf-3.03/xpdf/PDFDoc.h 2011-08-15 23:08:53.000000000 +0200 -@@ -154,27 +162,44 @@ - private: - - GBool setup(GString *ownerPassword, GString *userPassword); -+ GBool setup2(GString *ownerPassword, GString *userPassword, -+ GBool repairXRef); - void checkHeader(); - GBool checkEncryption(GString *ownerPassword, GString *userPassword); - - GString *fileName; - #ifdef WIN32 - wchar_t *fileNameU; - #endif - FILE *file; - BaseStream *str; - void *guiData; - double pdfVersion; - XRef *xref; - Catalog *catalog; - #ifndef DISABLE_OUTLINE - Outline *outline; - #endif diff -ru xpdf-3.02/xpdf/pdftotext.cc xpdf-3.03/xpdf/pdftotext.cc --- xpdf-3.02/xpdf/pdftotext.cc 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-3.03/xpdf/pdftotext.cc 2011-08-15 23:08:53.000000000 +0200 |