aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2020-12-22 15:31:26 +0100
committerJay Berkenbilt <ejb@ql.org>2020-12-26 14:48:18 +0100
commitcc8895078a1d64928e8ee335f1e8c7d6928de1b3 (patch)
treeb8f2ce902ae3a183f5e0a98951d6f7126cc13bc1 /qpdf
parent573b6eb8b1801b40a4b6eb32cfd159f532876510 (diff)
downloadqpdf-cc8895078a1d64928e8ee335f1e8c7d6928de1b3.tar.zst
Add QPDFObjectHandle::makeDirect(bool allow_streams)
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qpdf.testcov2
-rw-r--r--qpdf/qtest/qpdf.test11
-rw-r--r--qpdf/qtest/qpdf/test4-5.pdf152
-rw-r--r--qpdf/qtest/qpdf/test4-5.qdf177
-rw-r--r--qpdf/test_driver.cc8
5 files changed, 346 insertions, 4 deletions
diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov
index b109a162..15f6cf1e 100644
--- a/qpdf/qpdf.testcov
+++ b/qpdf/qpdf.testcov
@@ -79,7 +79,7 @@ QPDFObjectHandle clone string 0
QPDFObjectHandle clone array 0
QPDFObjectHandle clone dictionary 0
QPDFObjectHandle makeDirect loop 0
-QPDFObjectHandle ERR clone stream 0
+QPDFObjectHandle copy stream 1
QPDF default for xref stream field 0 0
QPDF prev key in xref stream dictionary 0
QPDF prev key in trailer dictionary 0
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index a786fa33..7dc7e261 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -2963,7 +2963,7 @@ $td->runtest("check output",
show_ntests();
# ----------
$td->notify("--- Mutability Tests ---");
-$n_tests += 4;
+$n_tests += 5;
$td->runtest("no normalization",
{$td->COMMAND => "test_driver 4 test4-1.pdf"},
@@ -2975,13 +2975,18 @@ $td->runtest("object ordering",
{$td->FILE => "test4-4.qdf",
$td->EXIT_STATUS => 0});
-$td->runtest("loop detected",
+$td->runtest("make direct with allow_streams",
+ {$td->COMMAND => "test_driver 4 test4-5.pdf"},
+ {$td->FILE => "test4-5.qdf",
+ $td->EXIT_STATUS => 0});
+
+$td->runtest("stream detected",
{$td->COMMAND => "test_driver 4 test4-2.pdf"},
{$td->FILE => "test4-2.out",
$td->EXIT_STATUS => 2},
$td->NORMALIZE_NEWLINES);
-$td->runtest("stream detected",
+$td->runtest("loop detected",
{$td->COMMAND => "test_driver 4 test4-3.pdf"},
{$td->FILE => "test4-3.out",
$td->EXIT_STATUS => 2},
diff --git a/qpdf/qtest/qpdf/test4-5.pdf b/qpdf/qtest/qpdf/test4-5.pdf
new file mode 100644
index 00000000..21fb0e9e
--- /dev/null
+++ b/qpdf/qtest/qpdf/test4-5.pdf
@@ -0,0 +1,152 @@
+%PDF-1.3
+%¿÷¢þ
+%QDF-1.0
+
+1 0 obj
+<<
+ /Pages 3 0 R
+ /Type /Catalog
+>>
+endobj
+
+2 0 obj
+<<
+ /A 4 0 R
+ /B 5 0 R
+ /Subject (Subject)
+ /Title (Some Title Is Here)
+>>
+endobj
+
+3 0 obj
+<<
+ /Count 1
+ /Kids [
+ 6 0 R
+ ]
+ /Type /Pages
+>>
+endobj
+
+4 0 obj
+[
+ 100
+ 2
+ 3
+]
+endobj
+
+5 0 obj
+<<
+ /A 4 0 R
+ /B (B)
+>>
+endobj
+
+%% Page 1
+6 0 obj
+<<
+ /Contents 7 0 R
+ /MediaBox [
+ 0
+ 0
+ 612
+ 792
+ ]
+ /Parent 3 0 R
+ /Resources <<
+ /Font <<
+ /F1 9 0 R
+ >>
+ /ProcSet 10 0 R
+ >>
+ /Type /Page
+>>
+endobj
+
+%% Contents for page 1
+7 0 obj
+<<
+ /Length 8 0 R
+>>
+stream
+BT
+ /F1 24 Tf
+ 72 720 Td
+ (Potato) Tj
+ET
+endstream
+endobj
+
+8 0 obj
+44
+endobj
+
+9 0 obj
+<<
+ /BaseFont /Helvetica
+ /Encoding /WinAnsiEncoding
+ /Name /F1
+ /Subtype /Type1
+ /Type /Font
+>>
+endobj
+
+10 0 obj
+[
+ /PDF
+ /Text
+]
+endobj
+
+11 0 obj
+<<
+ /A 12 0 R
+ /C (potato)
+>>
+endobj
+
+12 0 obj
+<< /B 13 0 R >>
+endobj
+
+13 0 obj
+<<
+ /Length 14 0 R
+>>
+stream
+salad
+endstream
+endobj
+
+14 0 obj
+6
+endobj
+
+xref
+0 15
+0000000000 65535 f
+0000000025 00000 n
+0000000079 00000 n
+0000000174 00000 n
+0000000246 00000 n
+0000000280 00000 n
+0000000332 00000 n
+0000000548 00000 n
+0000000647 00000 n
+0000000666 00000 n
+0000000784 00000 n
+0000000820 00000 n
+0000000869 00000 n
+0000000902 00000 n
+0000000965 00000 n
+trailer <<
+ /QTest 2 0 R
+ /QTest2 11 0 R
+ /Root 1 0 R
+ /Size 15
+ /ID [<c61bd35bada064f61e0a56aa9588064e><c893e7330be149468080ad6518819868>]
+>>
+startxref
+984
+%%EOF
diff --git a/qpdf/qtest/qpdf/test4-5.qdf b/qpdf/qtest/qpdf/test4-5.qdf
new file mode 100644
index 00000000..c1d83d4e
--- /dev/null
+++ b/qpdf/qtest/qpdf/test4-5.qdf
@@ -0,0 +1,177 @@
+%PDF-1.3
+%¿÷¢þ
+%QDF-1.0
+
+%% Original object ID: 1 0
+1 0 obj
+<<
+ /Pages 6 0 R
+ /Type /Catalog
+>>
+endobj
+
+%% Original object ID: 15 0
+2 0 obj
+<<
+ /A [
+ 14
+ 15
+ 9
+ ]
+ /Author (Mr. Potato Head)
+ /B <<
+ /A [
+ 100
+ 2
+ 3
+ ]
+ /B (B)
+ >>
+ /Title (Some Title Is Here)
+>>
+endobj
+
+%% Original object ID: 2 0
+3 0 obj
+<<
+ /A 7 0 R
+ /B 8 0 R
+ /Subject (Subject)
+ /Title (Some Title Is Here)
+>>
+endobj
+
+%% Original object ID: 13 0
+4 0 obj
+<<
+ /Length 5 0 R
+>>
+stream
+salad
+endstream
+endobj
+
+5 0 obj
+6
+endobj
+
+%% Original object ID: 3 0
+6 0 obj
+<<
+ /Count 1
+ /Kids [
+ 9 0 R
+ ]
+ /Type /Pages
+>>
+endobj
+
+%% Original object ID: 4 0
+7 0 obj
+[
+ 100
+ 2
+ 3
+]
+endobj
+
+%% Original object ID: 5 0
+8 0 obj
+<<
+ /A 7 0 R
+ /B (B)
+>>
+endobj
+
+%% Page 1
+%% Original object ID: 6 0
+9 0 obj
+<<
+ /Contents 10 0 R
+ /MediaBox [
+ 0
+ 0
+ 612
+ 792
+ ]
+ /Parent 6 0 R
+ /Resources <<
+ /Font <<
+ /F1 12 0 R
+ >>
+ /ProcSet 13 0 R
+ >>
+ /Type /Page
+>>
+endobj
+
+%% Contents for page 1
+%% Original object ID: 7 0
+10 0 obj
+<<
+ /Length 11 0 R
+>>
+stream
+BT
+ /F1 24 Tf
+ 72 720 Td
+ (Potato) Tj
+ET
+endstream
+endobj
+
+11 0 obj
+44
+endobj
+
+%% Original object ID: 9 0
+12 0 obj
+<<
+ /BaseFont /Helvetica
+ /Encoding /WinAnsiEncoding
+ /Name /F1
+ /Subtype /Type1
+ /Type /Font
+>>
+endobj
+
+%% Original object ID: 10 0
+13 0 obj
+[
+ /PDF
+ /Text
+]
+endobj
+
+xref
+0 14
+0000000000 65535 f
+0000000052 00000 n
+0000000134 00000 n
+0000000337 00000 n
+0000000460 00000 n
+0000000521 00000 n
+0000000566 00000 n
+0000000665 00000 n
+0000000726 00000 n
+0000000805 00000 n
+0000001050 00000 n
+0000001151 00000 n
+0000001198 00000 n
+0000001345 00000 n
+trailer <<
+ /Info 2 0 R
+ /QTest 3 0 R
+ /QTest2 <<
+ /A <<
+ /B 4 0 R
+ >>
+ /C (potato)
+ >>
+ /Root 1 0 R
+ /Size 14
+ /ID [<c61bd35bada064f61e0a56aa9588064e><31415926535897932384626433832795>]
+>>
+startxref
+1381
+%%EOF
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index 167c509b..68519e09 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -485,6 +485,14 @@ void runtest(int n, char const* filename1, char const* arg2)
A.setArrayFromVector(items);
}
+ QPDFObjectHandle qtest2 = trailer.getKey("/QTest2");
+ if (! qtest2.isNull())
+ {
+ // Test allow_streams=true
+ qtest2.makeDirect(true);
+ trailer.replaceKey("/QTest2", qtest2);
+ }
+
trailer.replaceKey("/Info", pdf.makeIndirectObject(qtest));
QPDFWriter w(pdf, 0);
w.setQDFMode(true);