Commit c16db4106c4c4c2fff0b0780b4da56426098340b

Authored by Jay Berkenbilt
1 parent 8318d81a

Increase padding in linearized files

With QPDF allowing integers to contain 64-bit quantities, this change
is necessary to be able to linearize files whose sizes might be larger
than 10 digits.
libqpdf/QPDFWriter.cc
... ... @@ -882,8 +882,7 @@ QPDFWriter::writeTrailer(trailer_e which, int size, bool xref_stream,
882 882 writeString(" /Prev ");
883 883 qpdf_offset_t pos = this->pipeline->getCount();
884 884 writeString(QUtil::int_to_string(prev));
885   - // XXX
886   - int nspaces = (int)(pos - this->pipeline->getCount() + 11);
  885 + int nspaces = (int)(pos - this->pipeline->getCount() + 21);
887 886 assert(nspaces >= 0);
888 887 writePad(nspaces);
889 888 }
... ... @@ -2122,9 +2121,10 @@ QPDFWriter::writeLinearized()
2122 2121 writeHeader();
2123 2122  
2124 2123 // Part 2: linearization parameter dictionary. Save enough
2125   - // space to write real dictionary. 150 characters is enough
  2124 + // space to write real dictionary. 200 characters is enough
2126 2125 // space if all numerical values in the parameter dictionary
2127   - // are 10 digits long plus a few extra characters for safety.
  2126 + // that contain offsets are 20 digits long plus a few extra
  2127 + // characters for safety.
2128 2128  
2129 2129 qpdf_offset_t pos = this->pipeline->getCount();
2130 2130 openObject(lindict_id);
... ... @@ -2154,7 +2154,7 @@ QPDFWriter::writeLinearized()
2154 2154 }
2155 2155 writeString(" >>");
2156 2156 closeObject(lindict_id);
2157   - static int const pad = 150;
  2157 + static int const pad = 200;
2158 2158 int spaces = (pos - this->pipeline->getCount() + pad);
2159 2159 assert(spaces >= 0);
2160 2160 writePad(spaces);
... ...
qpdf/qtest/qpdf/c-linearized.pdf
No preview for this file type
qpdf/qtest/qpdf/lin-special.disable.exp
No preview for this file type
qpdf/qtest/qpdf/lin-special.generate.exp
No preview for this file type
qpdf/qtest/qpdf/lin-special.preserve.exp
No preview for this file type
qpdf/qtest/qpdf/object-stream.disable.exp
No preview for this file type
qpdf/qtest/qpdf/object-stream.generate.exp
No preview for this file type
qpdf/qtest/qpdf/object-stream.preserve.exp
No preview for this file type