mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-02 22:50:20 +00:00
Fix logic for when to compress object and xref streams (fixes #271)
This commit is contained in:
parent
52f9d326a5
commit
2712869cf9
@ -1,5 +1,9 @@
|
|||||||
2019-01-28 Jay Berkenbilt <ejb@ql.org>
|
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,
|
* When linearizing or getting the list of all pages in a file,
|
||||||
replace duplicated page objects with a shallow copy of the page
|
replace duplicated page objects with a shallow copy of the page
|
||||||
object. Linearization and all page manipulation APIs require page
|
object. Linearization and all page manipulation APIs require page
|
||||||
|
4
TODO
4
TODO
@ -9,10 +9,6 @@ Soon
|
|||||||
latter is appropriate when a page is being converted to a form
|
latter is appropriate when a page is being converted to a form
|
||||||
XObject.
|
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
|
Next ABI
|
||||||
========
|
========
|
||||||
|
|
||||||
|
@ -1934,7 +1934,9 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object)
|
|||||||
|
|
||||||
// Set up a stream to write the stream data into a buffer.
|
// Set up a stream to write the stream data into a buffer.
|
||||||
Pipeline* next = pushPipeline(new Pl_Buffer("object stream"));
|
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;
|
compressed = true;
|
||||||
next = pushPipeline(
|
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"));
|
Pipeline* p = pushPipeline(new Pl_Buffer("xref stream"));
|
||||||
bool compressed = false;
|
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;
|
compressed = true;
|
||||||
if (! skip_compression)
|
if (! skip_compression)
|
||||||
|
@ -4417,6 +4417,13 @@ print "\n";
|
|||||||
pages tree.
|
pages tree.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</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>
|
</itemizedlist>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -1435,7 +1435,7 @@ foreach my $d (
|
|||||||
" $flags streams-with-newlines.pdf a.pdf"},
|
" $flags streams-with-newlines.pdf a.pdf"},
|
||||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||||
$td->NORMALIZE_NEWLINES);
|
$td->NORMALIZE_NEWLINES);
|
||||||
$td->runtest("check output",
|
$td->runtest("check output ($description)",
|
||||||
{$td->FILE => "a.pdf"},
|
{$td->FILE => "a.pdf"},
|
||||||
{$td->FILE => "newline-before-endstream-$suffix.pdf"});
|
{$td->FILE => "newline-before-endstream-$suffix.pdf"});
|
||||||
if ($flags =~ /qdf/)
|
if ($flags =~ /qdf/)
|
||||||
@ -2461,7 +2461,7 @@ for (my $n = 16; $n <= 19; ++$n)
|
|||||||
show_ntests();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
$td->notify("--- Specific File Tests ---");
|
$td->notify("--- Specific File Tests ---");
|
||||||
$n_tests += 2;
|
$n_tests += 4;
|
||||||
|
|
||||||
# Special PDF files that caused problems at some point
|
# 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->COMMAND => "qpdf-ctest 2 damaged-stream.pdf '' a.pdf"},
|
||||||
{$td->FILE => "damaged-stream-c-check.out", $td->EXIT_STATUS => 0},
|
{$td->FILE => "damaged-stream-c-check.out", $td->EXIT_STATUS => 0},
|
||||||
$td->NORMALIZE_NEWLINES);
|
$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();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
|
BIN
qpdf/qtest/qpdf/compress-objstm-xref.pdf
Normal file
BIN
qpdf/qtest/qpdf/compress-objstm-xref.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user