From c5f622a09e6a68d87d3591346d872cf828cf82c7 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 20 Dec 2023 10:51:56 -0500 Subject: [PATCH] Bug fix: don't compress object/xref streams with --compress-streams=n --- ChangeLog | 5 +++++ libqpdf/QPDFWriter.cc | 5 ++--- qpdf/qtest/qpdf/good17-not-recompressed.pdf | Bin 9147 -> 10621 bytes .../newline-before-endstream-nl-objstm.pdf | Bin 1203 -> 1730 bytes 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19be25a3..35a41ec0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-12-20 Jay Berkenbilt + + * Bug fix: with --compress-streams=n, don't compress object or + XRef streams. + 2023-12-16 Jay Berkenbilt * Add new C++ functions "qpdf_c_get_qpdf" and "qpdf_c_wrap" to diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 664ea5ff..3085e6c0 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -1658,8 +1658,7 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) // Set up a stream to write the stream data into a buffer. Pipeline* next = pushPipeline(new Pl_Buffer("object stream")); - if ((m->compress_streams || (m->stream_decode_level == qpdf_dl_none)) && - (!m->qdf_mode)) { + if (m->compress_streams && !m->qdf_mode) { compressed = true; next = pushPipeline(new Pl_Flate("compress object stream", next, Pl_Flate::a_deflate)); @@ -2417,7 +2416,7 @@ QPDFWriter::writeXRefStream( Pipeline* p = pushPipeline(new Pl_Buffer("xref stream")); bool compressed = false; - if ((m->compress_streams || (m->stream_decode_level == qpdf_dl_none)) && (!m->qdf_mode)) { + if (m->compress_streams && !m->qdf_mode) { compressed = true; if (!skip_compression) { // Write the stream dictionary for compression but don't actually compress. This helps diff --git a/qpdf/qtest/qpdf/good17-not-recompressed.pdf b/qpdf/qtest/qpdf/good17-not-recompressed.pdf index b6e3a5304c476fe9154f77d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