mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-30 18:38:52 +00:00
getRawStreamData()
git-svn-id: svn+q:///qpdf/trunk@1010 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
parent
54303cea9c
commit
bd7261da9b
@ -1,3 +1,8 @@
|
||||
2010-08-09 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* Add QPDFObjectHandle::getRawStreamData to return raw
|
||||
(unfiltered) stream data.
|
||||
|
||||
2010-08-08 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* 2.2.rc1: release
|
||||
|
2
TODO
2
TODO
@ -1,8 +1,6 @@
|
||||
2.2.0
|
||||
=====
|
||||
|
||||
* Add QPDFObjectHandle::getRawStreamData()
|
||||
|
||||
* shared library version information already bumped for 2.2.rc1;
|
||||
replace 2.2.rc1 with 2.2.0 in manual and update in other places for
|
||||
2.2.0.
|
||||
|
@ -216,6 +216,9 @@ class QPDFObjectHandle
|
||||
// exception if the stream is filtered and we can't decode it.
|
||||
QPDF_DLL
|
||||
PointerHolder<Buffer> getStreamData();
|
||||
// Returns unfiltered (raw) stream data.
|
||||
QPDF_DLL
|
||||
PointerHolder<Buffer> getRawStreamData();
|
||||
|
||||
// Write stream data through the given pipeline. A null pipeline
|
||||
// value may be used if all you want to do is determine whether a
|
||||
|
@ -343,6 +343,13 @@ QPDFObjectHandle::getStreamData()
|
||||
return dynamic_cast<QPDF_Stream*>(obj.getPointer())->getStreamData();
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
QPDFObjectHandle::getRawStreamData()
|
||||
{
|
||||
assertType("Stream", isStream());
|
||||
return dynamic_cast<QPDF_Stream*>(obj.getPointer())->getRawStreamData();
|
||||
}
|
||||
|
||||
bool
|
||||
QPDFObjectHandle::pipeStreamData(Pipeline* p, bool filter,
|
||||
bool normalize, bool compress)
|
||||
|
@ -75,6 +75,16 @@ QPDF_Stream::getStreamData()
|
||||
{
|
||||
throw std::logic_error("getStreamData called on unfilterable stream");
|
||||
}
|
||||
QTC::TC("qpdf", "QPDF_Stream getStreamData");
|
||||
return buf.getBuffer();
|
||||
}
|
||||
|
||||
PointerHolder<Buffer>
|
||||
QPDF_Stream::getRawStreamData()
|
||||
{
|
||||
Pl_Buffer buf("stream data buffer");
|
||||
pipeStreamData(&buf, false, false, false);
|
||||
QTC::TC("qpdf", "QPDF_Stream getRawStreamData");
|
||||
return buf.getBuffer();
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ class QPDF_Stream: public QPDFObject
|
||||
bool pipeStreamData(Pipeline*, bool filter,
|
||||
bool normalize, bool compress);
|
||||
PointerHolder<Buffer> getStreamData();
|
||||
PointerHolder<Buffer> getRawStreamData();
|
||||
void replaceStreamData(PointerHolder<Buffer> data,
|
||||
QPDFObjectHandle const& filter,
|
||||
QPDFObjectHandle const& decode_parms);
|
||||
|
@ -2105,6 +2105,16 @@ print "\n";
|
||||
removes the key instead.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Add new method in <classname>QPDFObjectHandle</classname>:
|
||||
<function>getRawStreamData</function>, which returns the raw
|
||||
(unfiltered) stream data into a buffer. This complements the
|
||||
<function>getStreamData</function> method, which returns the
|
||||
filtered (uncompressed) stream data and can only be used when
|
||||
the stream's data is filterable.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Provide two new examples:
|
||||
|
@ -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
|
||||
|
@ -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"},
|
||||
|
112
qpdf/qtest/qpdf/stream-data.pdf
Normal file
112
qpdf/qtest/qpdf/stream-data.pdf
Normal file
@ -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
|
3
qpdf/qtest/qpdf/test11.out
Normal file
3
qpdf/qtest/qpdf/test11.out
Normal file
@ -0,0 +1,3 @@
|
||||
filtered stream data okay
|
||||
raw stream data okay
|
||||
test 11 done
|
@ -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 ") +
|
||||
|
Loading…
x
Reference in New Issue
Block a user