From 9f8aba1db7f101e424cbc2c742abe92868cc4bff Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 7 Jun 2014 12:31:22 -0400 Subject: Handle indirect stream filter/decode parameters QPDFWriter was trying to make /Filter and /DecodeParms direct in all cases, but there are some cases where /DecodeParms may refer to a stream, which can't be direct. QPDFWriter doesn't actually need /DecodeParms to be direct in that case because it won't be able to filter the stream. Until we can handle this type of stream, just don't make /Filter and /DecodeParms direct if we can't filter the stream anyway. Fixes #34 --- libqpdf/QPDFWriter.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 0f299a45..08647e37 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -2051,11 +2051,14 @@ QPDFWriter::prepareFileForWrite() { bool is_stream = false; bool is_root = false; + bool filterable = false; QPDFObjectHandle dict = node; if (node.isStream()) { is_stream = true; dict = node.getDict(); + // See whether we are able to filter this stream. + filterable = node.pipeStreamData(0, true, false, false); } else if (pdf.getRoot().getObjectID() == node.getObjectID()) { @@ -2073,8 +2076,9 @@ QPDFWriter::prepareFileForWrite() { if (oh.isIndirect() && ((key == "/Length") || - (key == "/Filter") || - (key == "/DecodeParms"))) + (filterable && + ((key == "/Filter") || + (key == "/DecodeParms"))))) { QTC::TC("qpdf", "QPDFWriter make stream key direct"); add_to_queue = false; -- cgit v1.2.3-54-g00ecf