wgap,
wgap wrote:
>
> I have recently encountered documents without the trailer (IOException
> "trailer not found" when instantiating PdfReader).
>
> [...]
>
> I can not supply the PDF I received, due to its confidential content.
> I have, however, edited it with Acrobat 9 to remove all the content I
> could see, then saved it ("save as") to a file called
> test-saved-from-acrobat-9.pdf, which I am attaching.
>
I tried to reproduce your problem when instantiating a PdfReader with the
file you supplied:
public class test_saved_from_acrobat_9 extends TestCase {
public final static String FILENAME =
"data\\test-saved-from-acrobat-9.pdf";
public void testIsSigned() throws IOException {
PdfReader reader = new PdfReader(FILENAME);
System.out.println("Number of pages: " +
reader.getNumberOfPages());
}
}
Unfortunately this test failed to fail but happily printed "Number of pages:
2". Therefore, please also supply source code to reproduce the problem.
wgap wrote:
>
> Is the trailer element always required in a PDF document?
>
> [...]
>
> So, does anyone know more about this, i.e. whether in this situation it
> really is legitimate that the trailer is omitted?
>
As you found out yourself, the trailer as a stand-alone dictionary in the
finishing section of the document is not required anymore if you use a pure
XRef stream style PDF. The trailer data in this case are put into the XRef
stream dictionary, cf. the end of your sample file:
6 0 obj
<</DecodeParms<</Columns 3/Predictor
12>>/Filter/FlateDecode/ID[<A1D939E00AE7784D9D83389B62FC3B41><CEE713C9969C0A44BF1340BFCE5BEAB4>]/Info
8 0 R/Length 42/Root 10 0 R/Size 9/Type/XRef/W[1 2 0]>>stream
[...]
endstream
endobj
startxref
116
%%EOF
You see ID, Info, Root and Size there, the expected trailer data.
wgap wrote:
>
> And if so, is there a way to deal with this in iText? I am currently
> using iText 2.1.4.
>
iText easily can cope with such PDFs. I'm testing with the trunk version
which essentially is 2.1.6, but I think 2.1.4 already handles such PDFs
properly, too.
Regards, Michael.
--
View this message in context:
http://www.nabble.com/question-regarding-missing-trailer-tp23980977p23981556.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/