diff options
author | Jay Berkenbilt <ejb@ql.org> | 2010-08-10 01:33:40 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2010-08-10 01:33:40 +0200 |
commit | bd7261da9b3735688e8dcaeefe21294a1d13afd6 (patch) | |
tree | d953ffe0cacf5914996fae62282c1486d45c73d7 /qpdf | |
parent | 54303cea9c7ea78ba58eac648d20d3cbad729d4a (diff) | |
download | qpdf-bd7261da9b3735688e8dcaeefe21294a1d13afd6.tar.zst |
getRawStreamData()
git-svn-id: svn+q:///qpdf/trunk@1010 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/qpdf.testcov | 2 | ||||
-rw-r--r-- | qpdf/qtest/qpdf.test | 7 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/stream-data.pdf | 112 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/test11.out | 3 | ||||
-rw-r--r-- | qpdf/test_driver.cc | 17 |
5 files changed, 140 insertions, 1 deletions
diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov index 4a868227..f4354891 100644 --- a/qpdf/qpdf.testcov +++ b/qpdf/qpdf.testcov @@ -183,3 +183,5 @@ QPDFObjectHandle newStream with data 0 QPDF_Stream pipe no stream data 0 QPDFObjectHandle prepend page contents 0 QPDFObjectHandle append page contents 0 +QPDF_Stream getRawStreamData 0 +QPDF_Stream getStreamData 0 diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index 7d14722e..35b2be51 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -111,7 +111,7 @@ $td->runtest("new stream", show_ntests(); # ---------- $td->notify("--- Miscellaneous Tests ---"); -$n_tests += 22; +$n_tests += 23; $td->runtest("qpdf version", {$td->COMMAND => "qpdf --version"}, @@ -131,6 +131,11 @@ foreach (my $i = 1; $i <= 3; ++$i) $td->NORMALIZE_NEWLINES); } +$td->runtest("get stream data", + {$td->COMMAND => "test_driver 11 stream-data.pdf"}, + {$td->FILE => "test11.out", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); + # Make sure we ignore decode parameters that we don't understand $td->runtest("unknown decode parameters", {$td->COMMAND => "qpdf --check fax-decode-parms.pdf"}, diff --git a/qpdf/qtest/qpdf/stream-data.pdf b/qpdf/qtest/qpdf/stream-data.pdf new file mode 100644 index 00000000..61100863 --- /dev/null +++ b/qpdf/qtest/qpdf/stream-data.pdf @@ -0,0 +1,112 @@ +%PDF-1.3 +%¿÷¢þ +%QDF-1.0 + +1 0 obj +<< + /Pages 2 0 R + /QStream 3 0 R + /Type /Catalog +>> +endobj + +2 0 obj +<< + /Count 1 + /Kids [ + 5 0 R + ] + /Type /Pages +>> +endobj + +3 0 obj +<< + /Length 4 0 R + /Filter /ASCIIHexDecode +>> +stream +706F7461746F0A +endstream +endobj + +4 0 obj +15 +endobj + +%% Page 1 +5 0 obj +<< + /Contents 6 0 R + /MediaBox [ + 0 + 0 + 612 + 792 + ] + /Parent 2 0 R + /Resources << + /Font << + /F1 8 0 R + >> + /ProcSet 9 0 R + >> + /Type /Page +>> +endobj + +%% Contents for page 1 +6 0 obj +<< + /Length 7 0 R +>> +stream +BT + /F1 24 Tf + 72 720 Td + (Potato) Tj +ET +endstream +endobj + +7 0 obj +44 +endobj + +8 0 obj +<< + /BaseFont /Helvetica + /Encoding /WinAnsiEncoding + /Name /F1 + /Subtype /Type1 + /Type /Font +>> +endobj + +9 0 obj +[ + /PDF + /Text +] +endobj + +xref +0 10 +0000000000 65535 f +0000000025 00000 n +0000000096 00000 n +0000000168 00000 n +0000000264 00000 n +0000000293 00000 n +0000000508 00000 n +0000000607 00000 n +0000000626 00000 n +0000000744 00000 n +trailer << + /Root 1 0 R + /Size 10 + /ID [<422061d5d2701ad547ece6eb89b05b77><422061d5d2701ad547ece6eb89b05b77>] +>> +startxref +779 +%%EOF diff --git a/qpdf/qtest/qpdf/test11.out b/qpdf/qtest/qpdf/test11.out new file mode 100644 index 00000000..170f6b3d --- /dev/null +++ b/qpdf/qtest/qpdf/test11.out @@ -0,0 +1,3 @@ +filtered stream data okay +raw stream data okay +test 11 done diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index 710f4c6e..6eaec4bc 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -445,6 +445,23 @@ void runtest(int n, char const* filename) w.setStreamDataMode(qpdf_s_preserve); w.write(); } + else if (n == 11) + { + QPDFObjectHandle root = pdf.getRoot(); + QPDFObjectHandle qstream = root.getKey("/QStream"); + PointerHolder<Buffer> b1 = qstream.getStreamData(); + PointerHolder<Buffer> b2 = qstream.getRawStreamData(); + if ((b1.getPointer()->getSize() == 7) && + (memcmp(b1.getPointer()->getBuffer(), "potato\n", 7) == 0)) + { + std::cout << "filtered stream data okay" << std::endl; + } + if ((b2.getPointer()->getSize() == 15) && + (memcmp(b2.getPointer()->getBuffer(), "706F7461746F0A\n", 15) == 0)) + { + std::cout << "raw stream data okay" << std::endl; + } + } else { throw std::runtime_error(std::string("invalid test ") + |