Nevermind, the answer is found in COSWriter:
COSInteger cosInteger = COSInteger.get(the_bytes_to_write.length);
cosInteger.setDirect(true);
stream.getStream().setItem(COSName.LENGTH, cosInteger);
On 09/08/2014 09:24 AM, Frank Cornelis wrote:
Hi,
Per default PDFBox creates an object stream as follows:
1234 0 obj
<<
/Length 5678 0 R
>>
stream
...
endstream
endobj
However, what I would like to achieve is:
/Length 12345678
instead of a reference to an object that holds the length value.
I'm using the following code:
PDStream stream = new PDStream(new COSStream(new
RandomAccessBuffer()));
OutputStream outputStream = stream.createOutputStream();
IOUtils.write(the_bytes_to_write, outputStream);
outputStream.flush();
outputStream.close();
some_array_structure.add(new PDObjectStream(stream.getStream()));
If I try and add:
stream.getStream().setDirect(true);
I get an empty stream object. Is this a bug in PDFBox, or is there
another way to achieve this?
Kind Regards,
Frank.