aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--TODO4
-rw-r--r--libqpdf/QPDFWriter.cc8
-rw-r--r--manual/qpdf-manual.xml7
-rw-r--r--qpdf/qtest/qpdf.test13
-rw-r--r--qpdf/qtest/qpdf/compress-objstm-xref.pdfbin0 -> 743 bytes
6 files changed, 28 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index f24e1b75..180335f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2019-01-28 Jay Berkenbilt <ejb@ql.org>
+ * Bug fix: when using --stream-data=compress, object streams and
+ xref streams were not compressed. They were compressed if no
+ --stream-data option was specified. Fixes #271.
+
* When linearizing or getting the list of all pages in a file,
replace duplicated page objects with a shallow copy of the page
object. Linearization and all page manipulation APIs require page
diff --git a/TODO b/TODO
index 46d5d9df..42a348ed 100644
--- a/TODO
+++ b/TODO
@@ -9,10 +9,6 @@ Soon
latter is appropriate when a page is being converted to a form
XObject.
- * Look at the file for issue 271 (../misc/bugs/271/6059954.pdf) to
- figure out why the compression is bad and see if I can do anything
- about it.
-
Next ABI
========
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index c549728d..fee287bc 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -1934,7 +1934,9 @@ 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 (! (this->m->stream_decode_level || this->m->qdf_mode))
+ if ((this->m->compress_streams ||
+ (this->m->stream_decode_level == qpdf_dl_none)) &&
+ (! this->m->qdf_mode))
{
compressed = true;
next = pushPipeline(
@@ -2876,7 +2878,9 @@ QPDFWriter::writeXRefStream(int xref_id, int max_id, qpdf_offset_t max_offset,
Pipeline* p = pushPipeline(new Pl_Buffer("xref stream"));
bool compressed = false;
- if (! (this->m->stream_decode_level || this->m->qdf_mode))
+ if ((this->m->compress_streams ||
+ (this->m->stream_decode_level == qpdf_dl_none)) &&
+ (! this->m->qdf_mode))
{
compressed = true;
if (! skip_compression)
diff --git a/manual/qpdf-manual.xml b/manual/qpdf-manual.xml
index aaeaeb54..a724ba54 100644
--- a/manual/qpdf-manual.xml
+++ b/manual/qpdf-manual.xml
@@ -4417,6 +4417,13 @@ print "\n";
pages tree.
</para>
</listitem>
+ <listitem>
+ <para>
+ Using older option <option>--stream-data=compress</option>
+ with object streams, object streams and xref streams were
+ not compressed.
+ </para>
+ </listitem>
</itemizedlist>
</listitem>
<listitem>
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 9b72706f..85b9b8de 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -1435,7 +1435,7 @@ foreach my $d (
" $flags streams-with-newlines.pdf a.pdf"},
{$td->STRING => "", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
- $td->runtest("check output",
+ $td->runtest("check output ($description)",
{$td->FILE => "a.pdf"},
{$td->FILE => "newline-before-endstream-$suffix.pdf"});
if ($flags =~ /qdf/)
@@ -2461,7 +2461,7 @@ for (my $n = 16; $n <= 19; ++$n)
show_ntests();
# ----------
$td->notify("--- Specific File Tests ---");
-$n_tests += 2;
+$n_tests += 4;
# Special PDF files that caused problems at some point
@@ -2473,6 +2473,15 @@ $td->runtest("damaged stream (C)",
{$td->COMMAND => "qpdf-ctest 2 damaged-stream.pdf '' a.pdf"},
{$td->FILE => "damaged-stream-c-check.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
+$td->runtest("compress objstm and xref",
+ {$td->COMMAND =>
+ "qpdf --static-id --stream-data=compress".
+ " --object-streams=generate minimal.pdf a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("check output",
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "compress-objstm-xref.pdf"});
show_ntests();
# ----------
diff --git a/qpdf/qtest/qpdf/compress-objstm-xref.pdf b/qpdf/qtest/qpdf/compress-objstm-xref.pdf
new file mode 100644
index 00000000..a121ef24
--- /dev/null
+++ b/qpdf/qtest/qpdf/compress-objstm-xref.pdf
Binary files differ