summaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFWriter.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2014-06-07 18:31:22 +0200
committerJay Berkenbilt <ejb@ql.org>2014-06-07 22:31:03 +0200
commit9f8aba1db7f101e424cbc2c742abe92868cc4bff (patch)
tree11422a749e425f1f890694bebde3f7d9291c0040 /libqpdf/QPDFWriter.cc
parentb0a96ce6aa95c4d23e40eed3cede2f46e935bba7 (diff)
downloadqpdf-9f8aba1db7f101e424cbc2c742abe92868cc4bff.tar.zst
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
Diffstat (limited to 'libqpdf/QPDFWriter.cc')
-rw-r--r--libqpdf/QPDFWriter.cc8
1 files changed, 6 insertions, 2 deletions
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;