summaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2013-06-14 20:53:47 +0200
committerJay Berkenbilt <ejb@ql.org>2013-06-14 20:58:09 +0200
commita3576a73593987b26cd3eff346f8f7c11f713cbd (patch)
tree3db5b39d339cddacf2fc1b13ecf4c028bc0589b5 /qpdf
parent96eb96511557469d50bbd55d211ced16acc31e13 (diff)
downloadqpdf-a3576a73593987b26cd3eff346f8f7c11f713cbd.tar.zst
Bug fix: handle generation > 0 when generating object streams
Rework QPDFWriter to always track old object IDs and QPDFObjGen instead of int, thus not discarding the generation number. Switch to QPDF::getCompressibleObjGen() to properly handle the case of an old object eligible for compression that has a generation of other than zero.
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qpdf.testcov1
-rw-r--r--qpdf/qtest/qpdf.test11
-rw-r--r--qpdf/qtest/qpdf/gen1.pdf79
-rw-r--r--qpdf/qtest/qpdf/gen1.qdfbin0 -> 1259 bytes
4 files changed, 90 insertions, 1 deletions
diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov
index 31e15495..16650f73 100644
--- a/qpdf/qpdf.testcov
+++ b/qpdf/qpdf.testcov
@@ -262,3 +262,4 @@ qpdf-c called qpdf_set_r6_encryption_parameters 0
QPDFObjectHandle EOF in inline image 0
QPDFObjectHandle inline image token 0
QPDF not caching overridden objstm object 0
+QPDFWriter original obj non-zero gen 0
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 5ae2ae3c..30200ca1 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -199,7 +199,7 @@ $td->runtest("remove page we don't have",
show_ntests();
# ----------
$td->notify("--- Miscellaneous Tests ---");
-$n_tests += 62;
+$n_tests += 64;
$td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"},
@@ -501,6 +501,14 @@ $td->runtest("overridden compressed objects",
$td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
+$td->runtest("generate object streams for gen > 0",
+ {$td->COMMAND => "qpdf --qdf --static-id" .
+ " --object-streams=generate gen1.pdf a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
+$td->runtest("check file",
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "gen1.qdf"});
+
show_ntests();
# ----------
$td->notify("--- Numeric range parsing tests ---");
@@ -1183,6 +1191,7 @@ my @to_linearize =
'lin-delete-and-reuse', # linearized, then delete and reuse
'object-stream', # contains object streams
'hybrid-xref', # contains both xref tables and streams
+ 'gen1', # has objects with generation > 0
@linearized_files, # we should be able to relinearize
);
diff --git a/qpdf/qtest/qpdf/gen1.pdf b/qpdf/qtest/qpdf/gen1.pdf
new file mode 100644
index 00000000..6bfbbefe
--- /dev/null
+++ b/qpdf/qtest/qpdf/gen1.pdf
@@ -0,0 +1,79 @@
+%PDF-1.3
+1 1 obj
+<<
+ /Type /Catalog
+ /Pages 2 1 R
+>>
+endobj
+
+2 1 obj
+<<
+ /Type /Pages
+ /Kids [
+ 3 1 R
+ ]
+ /Count 1
+>>
+endobj
+
+3 1 obj
+<<
+ /Type /Page
+ /Parent 2 1 R
+ /MediaBox [0 0 612 792]
+ /Contents 4 1 R
+ /Resources <<
+ /ProcSet 5 1 R
+ /Font <<
+ /F1 6 1 R
+ >>
+ >>
+>>
+endobj
+
+4 1 obj
+<<
+ /Length 44
+>>
+stream
+BT
+ /F1 24 Tf
+ 72 720 Td
+ (Potato) Tj
+ET
+endstream
+endobj
+
+5 1 obj
+[
+ /PDF
+ /Text
+]
+endobj
+
+6 1 obj
+<<
+ /Type /Font
+ /Subtype /Type1
+ /Name /F1
+ /BaseFont /Helvetica
+ /Encoding /WinAnsiEncoding
+>>
+endobj
+
+xref
+0 7
+0000000000 65535 f
+0000000009 00001 n
+0000000063 00001 n
+0000000135 00001 n
+0000000307 00001 n
+0000000403 00001 n
+0000000438 00001 n
+trailer <<
+ /Size 7
+ /Root 1 1 R
+>>
+startxref
+556
+%%EOF
diff --git a/qpdf/qtest/qpdf/gen1.qdf b/qpdf/qtest/qpdf/gen1.qdf
new file mode 100644
index 00000000..802bf2bc
--- /dev/null
+++ b/qpdf/qtest/qpdf/gen1.qdf
Binary files differ