From d61612a2e54d266d8fc4f55042080b780984272e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 20 Dec 2023 11:08:36 -0500 Subject: Bug fix: don't compress hint streams when --compress-streams=n --- libqpdf/QPDF_linearization.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'libqpdf/QPDF_linearization.cc') diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc index 469b9933..1657d54a 100644 --- a/libqpdf/QPDF_linearization.cc +++ b/libqpdf/QPDF_linearization.cc @@ -1748,10 +1748,10 @@ QPDF::writeHSharedObject(BitWriter& w) void QPDF::writeHGeneric(BitWriter& w, HGeneric& t) { - w.writeBitsInt(t.first_object, 32); // 1 - w.writeBits(toULL(t.first_object_offset), 32); // 2 - w.writeBitsInt(t.nobjects, 32); // 3 - w.writeBitsInt(t.group_length, 32); // 4 + w.writeBitsInt(t.first_object, 32); // 1 + w.writeBits(toULL(t.first_object_offset), 32); // 2 + w.writeBitsInt(t.nobjects, 32); // 3 + w.writeBitsInt(t.group_length, 32); // 4 } void @@ -1761,7 +1761,8 @@ QPDF::generateHintStream( std::map const& obj_renumber, std::shared_ptr& hint_buffer, int& S, - int& O) + int& O, + bool compressed) { // Populate actual hint table values calculateHPageOffset(xref, lengths, obj_renumber); @@ -1771,8 +1772,14 @@ QPDF::generateHintStream( // Write the hint stream itself into a compressed memory buffer. Write through a counter so we // can get offsets. Pl_Buffer hint_stream("hint stream"); - Pl_Flate f("compress hint stream", &hint_stream, Pl_Flate::a_deflate); - Pl_Count c("count", &f); + Pipeline* next = &hint_stream; + std::shared_ptr flate; + if (compressed) { + flate = + std::make_shared("compress hint stream", &hint_stream, Pl_Flate::a_deflate); + next = flate.get(); + } + Pl_Count c("count", next); BitWriter w(&c); writeHPageOffset(w); -- cgit v1.2.3-70-g09d2