From f394d5adac3564677ded18bcc9e27fd75523ae1c Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Mon, 4 Nov 2013 20:07:15 +1030 Subject: [PATCH 5/8] Make PDFWriter work with encrypted documents The output needs to be unencrypted for printing. --- poppler/PDFDoc.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 835dbb4..ab02eda 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -1144,7 +1144,16 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO //We can't modify stream with the current implementation (no write functions in Stream API) // => the only type of streams which that have been modified are internal streams (=strWeird) Stream *stream = obj->getStream(); - if (stream->getKind() == strWeird || stream->getKind() == strCrypt) { + GBool encrypted = gFalse; + Stream *str = stream; + while (str) { + if (str->getKind() == strCrypt) { + encrypted = gTrue; + break; + } + str = str->getNextStream(); + } + if (encrypted || stream->getKind() == strWeird) { //we write the stream unencoded => TODO: write stream encoder // Encrypt stream -- 1.8.3.2