Hello again, Am 01.09.2015 um 23:48 schrieb Albert Astals Cid: > El Dimarts, 1 de setembre de 2015, a les 23:34:10, Adam Reichold va escriure: > I've reverted the change altogether until we find a way to solve this.
Attached is an extension of the original patch series which adds the necessary change to replace raw stream copying with "undecoded" stream copying as it is for example used in the PostScript output device to transfer compressed (but decrypted) image data. This way, filters like compression stay intact and stream nesting is only undone until a decryption stream is reached. I also opted to continue to pass the "stripEncryption" flag explicitly instead of for example testing fileKey != NULL && stream->getBaseStream() != stream->getUndecodedStream() so that while the patch is larger, we can be more assured not to disturb the current code paths as this change is triggered only by explicit request of the caller. Best regards, Adam.
From 4ada96d6b1e3e1fdaee4ec98af42f0e03de2d735 Mon Sep 17 00:00:00 2001 From: Adam Reichold <[email protected]> Date: Sat, 25 Jul 2015 14:06:46 +0200 Subject: [PATCH 1/3] Add option to strip encryption Adds a PDF write mode that forces a complete rewrite that ignores the original encryption parameters of the document and also removes the encryption entry from the trailer dictionary. --- poppler/PDFDoc.cc | 31 ++++++++++++++++++------------- poppler/PDFDoc.h | 9 +++++---- utils/pdfunite.cc | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 46c4544..dd83d9a 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -763,7 +763,7 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) Ref ref; ref.num = rootNum; ref.gen = 0; - Dict *trailerDict = createTrailerDict(rootNum + 3, gFalse, 0, &ref, getXRef(), + Dict *trailerDict = createTrailerDict(rootNum + 3, gFalse, gFalse, 0, &ref, getXRef(), name->getCString(), uxrefOffset); writeXRefTableTrailer(trailerDict, yRef, gFalse /* do not write unnecessary entries */, uxrefOffset, outStr, getXRef()); @@ -809,7 +809,10 @@ int PDFDoc::saveAs(OutStream *outStr, PDFWriteMode mode) { // simply copy the original file saveWithoutChangesAs (outStr); } else if (mode == writeForceRewrite) { - saveCompleteRewrite(outStr); + saveCompleteRewrite(outStr, false); + } else if (mode == writeStripEncryption) { + // do a complete rewrite ignoring the original encryption parameters + saveCompleteRewrite(outStr, true); } else { saveIncrementalUpdate(outStr); } @@ -916,7 +919,7 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr) uxref->add(uxrefStreamRef.num, uxrefStreamRef.gen, uxrefOffset, gTrue); } - Dict *trailerDict = createTrailerDict(numobjects, gTrue, getStartXRef(), &rootRef, getXRef(), fileNameA, uxrefOffset); + Dict *trailerDict = createTrailerDict(numobjects, gTrue, gFalse, getStartXRef(), &rootRef, getXRef(), fileNameA, uxrefOffset); if (xRefStream) { writeXRefStreamTrailer(trailerDict, uxref, &uxrefStreamRef, uxrefOffset, outStr, getXRef()); } else { @@ -927,16 +930,18 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr) delete uxref; } -void PDFDoc::saveCompleteRewrite (OutStream* outStr) +void PDFDoc::saveCompleteRewrite (OutStream* outStr, GBool stripEncryption) { // Make sure that special flags are set, because we are going to read // all objects, including Unencrypted ones. xref->scanSpecialFlags(); - Guchar *fileKey; - CryptAlgorithm encAlgorithm; - int keyLength; - xref->getEncryptionParameters(&fileKey, &encAlgorithm, &keyLength); + Guchar *fileKey = NULL; + CryptAlgorithm encAlgorithm = cryptRC4; + int keyLength = 0; + + if (!stripEncryption) + xref->getEncryptionParameters(&fileKey, &encAlgorithm, &keyLength); outStr->printf("%%PDF-%d.%d\r\n",pdfMajorVersion,pdfMinorVersion); XRef *uxref = new XRef(); @@ -986,7 +991,7 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr) xref->unlock(); Goffset uxrefOffset = outStr->getPos(); writeXRefTableTrailer(uxrefOffset, uxref, gTrue /* write all entries */, - uxref->getNumObjects(), outStr, gFalse /* complete rewrite */); + uxref->getNumObjects(), outStr, gFalse /* complete rewrite */, stripEncryption); delete uxref; } @@ -1269,7 +1274,7 @@ void PDFDoc::writeObjectFooter (OutStream* outStr) outStr->printf("endobj\r\n"); } -Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxRef, +Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, GBool stripEncryption, Goffset startxRef, Ref *root, XRef *xRef, const char *fileName, Goffset fileSize) { Dict *trailerDict = new Dict(xRef); @@ -1308,7 +1313,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxR obj1.free(); GBool hasEncrypt = gFalse; - if (!xRef->getTrailerDict()->isNone()) { + if (!stripEncryption && !xRef->getTrailerDict()->isNone()) { Object obj2; xRef->getTrailerDict()->dictLookupNF("Encrypt", &obj2); if (!obj2.isNull()) { @@ -1401,7 +1406,7 @@ void PDFDoc::writeXRefStreamTrailer (Dict *trailerDict, XRef *uxref, Ref *uxrefS } void PDFDoc::writeXRefTableTrailer(Goffset uxrefOffset, XRef *uxref, GBool writeAllEntries, - int uxrefSize, OutStream* outStr, GBool incrUpdate) + int uxrefSize, OutStream* outStr, GBool incrUpdate, GBool stripEncryption) { const char *fileNameA = fileName ? fileName->getCString() : NULL; // file size (doesn't include the trailer) @@ -1415,7 +1420,7 @@ void PDFDoc::writeXRefTableTrailer(Goffset uxrefOffset, XRef *uxref, GBool write Ref ref; ref.num = getXRef()->getRootNum(); ref.gen = getXRef()->getRootGen(); - Dict * trailerDict = createTrailerDict(uxrefSize, incrUpdate, getStartXRef(), &ref, + Dict * trailerDict = createTrailerDict(uxrefSize, incrUpdate, stripEncryption, getStartXRef(), &ref, getXRef(), fileNameA, fileSize); writeXRefTableTrailer(trailerDict, uxref, writeAllEntries, uxrefOffset, outStr, getXRef()); delete trailerDict; diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index 6c40f7b..7f55946 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -66,7 +66,8 @@ class StructTreeRoot; enum PDFWriteMode { writeStandard, writeForceRewrite, - writeForceIncremental + writeForceIncremental, + writeStripEncryption }; //------------------------------------------------------------------------ @@ -258,7 +259,7 @@ public: static void writeHeader(OutStream *outStr, int major, int minor); // Ownership goes to the caller - static Dict *createTrailerDict (int uxrefSize, GBool incrUpdate, Goffset startxRef, + static Dict *createTrailerDict (int uxrefSize, GBool incrUpdate, GBool stripEncryption, Goffset startxRef, Ref *root, XRef *xRef, const char *fileName, Goffset fileSize); static void writeXRefTableTrailer (Dict *trailerDict, XRef *uxref, GBool writeAllEntries, Goffset uxrefOffset, OutStream* outStr, XRef *xRef); @@ -285,11 +286,11 @@ private: static void writeStream (Stream* str, OutStream* outStr); static void writeRawStream (Stream* str, OutStream* outStr); void writeXRefTableTrailer (Goffset uxrefOffset, XRef *uxref, GBool writeAllEntries, - int uxrefSize, OutStream* outStr, GBool incrUpdate); + int uxrefSize, OutStream* outStr, GBool incrUpdate, GBool stripEncryption); static void writeString (GooString* s, OutStream* outStr, Guchar *fileKey, CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen); void saveIncrementalUpdate (OutStream* outStr); - void saveCompleteRewrite (OutStream* outStr); + void saveCompleteRewrite (OutStream* outStr, GBool stripEncryption); Page *parsePage(int page); diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc index 19a1eb5..14442f8 100644 --- a/utils/pdfunite.cc +++ b/utils/pdfunite.cc @@ -450,7 +450,7 @@ int main (int argc, char *argv[]) Ref ref; ref.num = rootNum; ref.gen = 0; - Dict *trailerDict = PDFDoc::createTrailerDict(objectsCount, gFalse, 0, &ref, yRef, + Dict *trailerDict = PDFDoc::createTrailerDict(objectsCount, gFalse, gFalse, 0, &ref, yRef, fileName, outStr->getPos()); PDFDoc::writeXRefTableTrailer(trailerDict, yRef, gTrue, // write all entries according to ISO 32000-1, 7.5.4 Cross-Reference Table: "For a file that has never been incrementally updated, the cross-reference section shall contain only one subsection, whose object numbering begins at 0." uxrefOffset, outStr, yRef); -- 2.5.1 From 9aff0b88d2313140467a5391f285123443bfc715 Mon Sep 17 00:00:00 2001 From: Adam Reichold <[email protected]> Date: Sat, 25 Jul 2015 14:08:16 +0200 Subject: [PATCH 2/3] [Qt] Add force-write and strip-encryption flags Extend the PDF converter options by two flags that force a rewrite and optionally strip the encryption from the document. --- qt4/src/poppler-pdf-converter.cc | 13 ++++++++++++- qt4/src/poppler-qt4.h | 4 +++- qt5/src/poppler-pdf-converter.cc | 13 ++++++++++++- qt5/src/poppler-qt5.h | 4 +++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/qt4/src/poppler-pdf-converter.cc b/qt4/src/poppler-pdf-converter.cc index 9699b75..8350267 100644 --- a/qt4/src/poppler-pdf-converter.cc +++ b/qt4/src/poppler-pdf-converter.cc @@ -92,7 +92,18 @@ bool PDFConverter::convert() QIODeviceOutStream stream(dev); if (d->opts & WithChanges) { - errorCode = d->document->doc->saveAs(&stream); + PDFWriteMode mode = writeStandard; + + if (d->opts & StripEncryption) + { + mode = writeStripEncryption; + } + else if (d->opts & ForceRewrite) + { + mode = writeForceRewrite; + } + + errorCode = d->document->doc->saveAs(&stream, mode); } else { diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h index c0340a4..fb65e11 100644 --- a/qt4/src/poppler-qt4.h +++ b/qt4/src/poppler-qt4.h @@ -1668,7 +1668,9 @@ height = dummy.height(); Options for the PDF export. */ enum PDFOption { - WithChanges = 0x00000001 ///< The changes done to the document are saved as well + WithChanges = 0x00000001, ///< The changes done to the document are saved as well + ForceRewrite = 0x00000002, ///< The document is rewritten instead of update incrementally (only applicable if WithChanges is also set) \since 0.35 + StripEncryption = 0x00000004 ///< The document is saved without encryption (only applicable if WithChanges is also set and implies ForceRewrite) \since 0.35 }; Q_DECLARE_FLAGS( PDFOptions, PDFOption ) diff --git a/qt5/src/poppler-pdf-converter.cc b/qt5/src/poppler-pdf-converter.cc index 557a9f8..c198c09 100644 --- a/qt5/src/poppler-pdf-converter.cc +++ b/qt5/src/poppler-pdf-converter.cc @@ -92,7 +92,18 @@ bool PDFConverter::convert() QIODeviceOutStream stream(dev); if (d->opts & WithChanges) { - errorCode = d->document->doc->saveAs(&stream); + PDFWriteMode mode = writeStandard; + + if (d->opts & StripEncryption) + { + mode = writeStripEncryption; + } + else if (d->opts & ForceRewrite) + { + mode = writeForceRewrite; + } + + errorCode = d->document->doc->saveAs(&stream, mode); } else { diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index b159477..80e87d7 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -1629,7 +1629,9 @@ height = dummy.height(); Options for the PDF export. */ enum PDFOption { - WithChanges = 0x00000001 ///< The changes done to the document are saved as well + WithChanges = 0x00000001, ///< The changes done to the document are saved as well + ForceRewrite = 0x00000002, ///< The document is rewritten instead of update incrementally (only applicable if WithChanges is also set) \since 0.35 + StripEncryption = 0x00000004 ///< The document is saved without encryption (only applicable if WithChanges is also set and implies ForceRewrite) \since 0.35 }; Q_DECLARE_FLAGS( PDFOptions, PDFOption ) -- 2.5.1 From ebc6440b501316025f11b9d374dbf07129f71735 Mon Sep 17 00:00:00 2001 From: Adam Reichold <[email protected]> Date: Wed, 2 Sep 2015 00:45:05 +0200 Subject: [PATCH 3/3] Disable raw stream copy when stripping encryption If we are stripping a documents encryption, a raw stream copy can write encrypted data into the resulting document since various streams might actually be based on a decryption stream. This changes the stream copying in this case to only undo stream nesting until a decryption stream is reached so that dependent filters like compression stay intact. --- poppler/PDFDoc.cc | 54 +++++++++++++++++++++++++++++++++++------------------- poppler/PDFDoc.h | 12 ++++++------ utils/pdfunite.cc | 10 +++++----- 3 files changed, 46 insertions(+), 30 deletions(-) diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index dd83d9a..0950406 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -722,7 +722,7 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) if (j > 0) outStr->printf(" "); Object value; catDict->getValNF(j, &value); outStr->printf("/%s ", key); - writeObject(&value, outStr, getXRef(), 0, NULL, cryptRC4, 0, 0, 0); + writeObject(&value, outStr, getXRef(), 0, NULL, cryptRC4, 0, gFalse, 0, 0); value.free(); } } @@ -735,7 +735,7 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) outStr->printf("<< /Type /Pages /Kids [ %d 0 R ] /Count 1 ", rootNum + 2); if (resourcesObj.isDict()) { outStr->printf("/Resources "); - writeObject(&resourcesObj, outStr, getXRef(), 0, NULL, cryptRC4, 0, 0, 0); + writeObject(&resourcesObj, outStr, getXRef(), 0, NULL, cryptRC4, 0, gFalse, 0, 0); resourcesObj.free(); } outStr->printf(">>\n"); @@ -752,7 +752,7 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) outStr->printf("/Parent %d 0 R", rootNum + 1); } else { outStr->printf("/%s ", key); - writeObject(&value, outStr, getXRef(), 0, NULL, cryptRC4, 0, 0, 0); + writeObject(&value, outStr, getXRef(), 0, NULL, cryptRC4, 0, gFalse, 0, 0); } value.free(); } @@ -887,7 +887,7 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr) Object obj1; xref->fetch(ref.num, ref.gen, &obj1, 1); Goffset offset = writeObjectHeader(&ref, outStr); - writeObject(&obj1, outStr, fileKey, encAlgorithm, keyLength, ref.num, ref.gen); + writeObject(&obj1, outStr, fileKey, encAlgorithm, keyLength, gFalse, ref.num, ref.gen); writeObjectFooter(outStr); uxref->add(ref.num, ref.gen, offset, gTrue); obj1.free(); @@ -970,9 +970,9 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr, GBool stripEncryption) Goffset offset = writeObjectHeader(&ref, outStr); // Write unencrypted objects in unencrypted form if (xref->getEntry(i)->getFlag(XRefEntry::Unencrypted)) { - writeObject(&obj1, outStr, NULL, cryptRC4, 0, 0, 0); + writeObject(&obj1, outStr, NULL, cryptRC4, 0, gFalse, 0, 0); } else { - writeObject(&obj1, outStr, fileKey, encAlgorithm, keyLength, ref.num, ref.gen); + writeObject(&obj1, outStr, fileKey, encAlgorithm, keyLength, stripEncryption, ref.num, ref.gen); } writeObjectFooter(outStr); uxref->add(ref.num, ref.gen, offset, gTrue); @@ -982,7 +982,7 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr, GBool stripEncryption) ref.gen = 0; //compressed entries have gen == 0 xref->fetch(ref.num, ref.gen, &obj1, 1); Goffset offset = writeObjectHeader(&ref, outStr); - writeObject(&obj1, outStr, fileKey, encAlgorithm, keyLength, ref.num, ref.gen); + writeObject(&obj1, outStr, fileKey, encAlgorithm, keyLength, stripEncryption, ref.num, ref.gen); writeObjectFooter(outStr); uxref->add(ref.num, ref.gen, offset, gTrue); obj1.free(); @@ -996,7 +996,7 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr, GBool stripEncryption) } void PDFDoc::writeDictionnary (Dict* dict, OutStream* outStr, XRef *xRef, Guint numOffset, Guchar *fileKey, - CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen) + CryptAlgorithm encAlgorithm, int keyLength, GBool stripEncryption, int objNum, int objGen) { Object obj1; outStr->printf("<<"); @@ -1005,7 +1005,7 @@ void PDFDoc::writeDictionnary (Dict* dict, OutStream* outStr, XRef *xRef, Guint GooString *keyNameToPrint = keyName.sanitizedName(gFalse /* non ps mode */); outStr->printf("/%s ", keyNameToPrint->getCString()); delete keyNameToPrint; - writeObject(dict->getValNF(i, &obj1), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); + writeObject(dict->getValNF(i, &obj1), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, stripEncryption, objNum, objGen); obj1.free(); } outStr->printf(">> "); @@ -1115,7 +1115,7 @@ Goffset PDFDoc::writeObjectHeader (Ref *ref, OutStream* outStr) } void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numOffset, Guchar *fileKey, - CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen) + CryptAlgorithm encAlgorithm, int keyLength, GBool stripEncryption, int objNum, int objGen) { Array *array; Object obj1; @@ -1156,13 +1156,13 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO array = obj->getArray(); outStr->printf("["); for (int i=0; i<array->getLength(); i++) { - writeObject(array->getNF(i, &obj1), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); + writeObject(array->getNF(i, &obj1), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, stripEncryption, objNum, objGen); obj1.free(); } outStr->printf("] "); break; case objDict: - writeDictionnary (obj->getDict(), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); + writeDictionnary (obj->getDict(), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, stripEncryption, objNum, objGen); break; case objStream: { @@ -1225,10 +1225,26 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO } stream->getDict()->remove("DecodeParms"); - writeDictionnary (stream->getDict(),outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); + writeDictionnary (stream->getDict(),outStr, xRef, numOffset, fileKey, encAlgorithm, stripEncryption, keyLength, objNum, objGen); writeStream (stream,outStr); delete encStream; obj1.free(); + } else if (stripEncryption) { + // Undo stream nesting until a Crypt stream is reached. + stream = stream->getUndecodedStream(); + + // Recompute the resulting stream length. + stream->reset(); + tmp = 0; + while (stream->getChar() != EOF) { + tmp++; + } + obj1.initInt64(tmp); + stream->getDict()->set("Length", &obj1); + + writeDictionnary (stream->getDict(),outStr, xRef, numOffset, fileKey, encAlgorithm, stripEncryption, keyLength, objNum, objGen); + writeStream (stream,outStr); + obj1.free(); } else { //raw stream copy FilterStream *fs = dynamic_cast<FilterStream*>(stream); @@ -1243,7 +1259,7 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO } } } - writeDictionnary (stream->getDict(), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); + writeDictionnary (stream->getDict(), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, stripEncryption, objNum, objGen); writeRawStream (stream, outStr); } break; @@ -1378,7 +1394,7 @@ void PDFDoc::writeXRefTableTrailer(Dict *trailerDict, XRef *uxref, GBool writeAl { uxref->writeTableToFile( outStr, writeAllEntries ); outStr->printf( "trailer\r\n"); - writeDictionnary(trailerDict, outStr, xRef, 0, NULL, cryptRC4, 0, 0, 0); + writeDictionnary(trailerDict, outStr, xRef, 0, NULL, cryptRC4, 0, gFalse, 0, 0); outStr->printf( "\r\nstartxref\r\n"); outStr->printf( "%lli\r\n", uxrefOffset); outStr->printf( "%%%%EOF\r\n"); @@ -1396,7 +1412,7 @@ void PDFDoc::writeXRefStreamTrailer (Dict *trailerDict, XRef *uxref, Ref *uxrefS MemStream *mStream = new MemStream( stmData.getCString(), 0, stmData.getLength(), obj1.initDict(trailerDict) ); writeObjectHeader(uxrefStreamRef, outStr); - writeObject(obj1.initStream(mStream), outStr, xRef, 0, NULL, cryptRC4, 0, 0, 0); + writeObject(obj1.initStream(mStream), outStr, xRef, 0, NULL, cryptRC4, 0, gFalse, 0, 0); writeObjectFooter(outStr); obj1.free(); @@ -1756,11 +1772,11 @@ Guint PDFDoc::writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset, G getXRef()->fetch(ref.num - numOffset, ref.gen, &obj); Goffset offset = writeObjectHeader(&ref, outStr); if (combine) { - writeObject(&obj, outStr, getXRef(), numOffset, NULL, cryptRC4, 0, 0, 0); + writeObject(&obj, outStr, getXRef(), numOffset, NULL, cryptRC4, 0, gFalse, 0, 0); } else if (xRef->getEntry(n)->getFlag(XRefEntry::Unencrypted)) { - writeObject(&obj, outStr, NULL, cryptRC4, 0, 0, 0); + writeObject(&obj, outStr, NULL, cryptRC4, 0, gFalse, 0, 0); } else { - writeObject(&obj, outStr, fileKey, encAlgorithm, keyLength, ref.num, ref.gen); + writeObject(&obj, outStr, fileKey, encAlgorithm, keyLength, gFalse, ref.num, ref.gen); } writeObjectFooter(outStr); xRef->add(ref.num, ref.gen, offset, gTrue); diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index 7f55946..03047fa 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -255,7 +255,7 @@ public: // write all objects used by pageDict to outStr Guint writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset, GBool combine = gFalse); static void writeObject (Object *obj, OutStream* outStr, XRef *xref, Guint numOffset, Guchar *fileKey, - CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen); + CryptAlgorithm encAlgorithm, int keyLength, GBool stripEncryption, int objNum, int objGen); static void writeHeader(OutStream *outStr, int major, int minor); // Ownership goes to the caller @@ -271,18 +271,18 @@ private: void markDictionnary (Dict* dict, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum); void markObject (Object *obj, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum); static void writeDictionnary (Dict* dict, OutStream* outStr, XRef *xRef, Guint numOffset, Guchar *fileKey, - CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen); + CryptAlgorithm encAlgorithm, int keyLength, GBool stripEncryption, int objNum, int objGen); // Write object header to current file stream and return its offset static Goffset writeObjectHeader (Ref *ref, OutStream* outStr); static void writeObjectFooter (OutStream* outStr); void writeObject (Object *obj, OutStream* outStr, Guchar *fileKey, CryptAlgorithm encAlgorithm, - int keyLength, int objNum, int objGen) - { writeObject(obj, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, objNum, objGen); } + int keyLength, GBool stripEncryption, int objNum, int objGen) + { writeObject(obj, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, stripEncryption, objNum, objGen); } void writeDictionnary (Dict* dict, OutStream* outStr, Guchar *fileKey, CryptAlgorithm encAlgorithm, - int keyLength, int objNum, int objGen) - { writeDictionnary(dict, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, objNum, objGen); } + int keyLength, GBool stripEncryption, int objNum, int objGen) + { writeDictionnary(dict, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, stripEncryption, objNum, objGen); } static void writeStream (Stream* str, OutStream* outStr); static void writeRawStream (Stream* str, OutStream* outStr); void writeXRefTableTrailer (Goffset uxrefOffset, XRef *uxref, GBool writeAllEntries, diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc index 14442f8..fe418a3 100644 --- a/utils/pdfunite.cc +++ b/utils/pdfunite.cc @@ -388,7 +388,7 @@ int main (int argc, char *argv[]) Object intent; intents.arrayGet(j, &intent, 0); if (intent.isDict()) { - PDFDoc::writeObject(&intent, outStr, yRef, 0, NULL, cryptRC4, 0, 0, 0); + PDFDoc::writeObject(&intent, outStr, yRef, 0, NULL, cryptRC4, 0, gFalse, 0, 0); } intent.free(); } @@ -398,19 +398,19 @@ int main (int argc, char *argv[]) // insert AcroForm if (!afObj.isNull()) { outStr->printf(" /AcroForm "); - PDFDoc::writeObject(&afObj, outStr, yRef, 0, NULL, cryptRC4, 0, 0, 0); + PDFDoc::writeObject(&afObj, outStr, yRef, 0, NULL, cryptRC4, 0, gFalse, 0, 0); afObj.free(); } // insert OCProperties if (!ocObj.isNull() && ocObj.isDict()) { outStr->printf(" /OCProperties "); - PDFDoc::writeObject(&ocObj, outStr, yRef, 0, NULL, cryptRC4, 0, 0, 0); + PDFDoc::writeObject(&ocObj, outStr, yRef, 0, NULL, cryptRC4, 0, gFalse, 0, 0); ocObj.free(); } // insert Names if (!names.isNull() && names.isDict()) { outStr->printf(" /Names "); - PDFDoc::writeObject(&names, outStr, yRef, 0, NULL, cryptRC4, 0, 0, 0); + PDFDoc::writeObject(&names, outStr, yRef, 0, NULL, cryptRC4, 0, gFalse, 0, 0); names.free(); } outStr->printf(">>\nendobj\n"); @@ -439,7 +439,7 @@ int main (int argc, char *argv[]) outStr->printf("/Parent %d 0 R", rootNum + 1); } else { outStr->printf("/%s ", key); - PDFDoc::writeObject(&value, outStr, yRef, offsets[i], NULL, cryptRC4, 0, 0, 0); + PDFDoc::writeObject(&value, outStr, yRef, offsets[i], NULL, cryptRC4, 0, gFalse, 0, 0); } value.free(); } -- 2.5.1
signature.asc
Description: OpenPGP digital signature
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
