Michael,
Thank you very much for the feedback. I'm sorry I did not read all of
your response earlier -- I was replying to Leonard and Bruno.
Especially the comment you made regarding an "XRef stream style PDF" was
very useful -- this tells me that there are indeed cases where a PDF
legitimately does not have a trailer.
I think there must be something else wrong with the original file. I,
too, had no problem instantiating PdfReader with the file produced by
Acrobat via "Save As". The original file, however, causes the "missing
trailer" exception. Both files have no trailer, but the original
clearly has some other issue which is causing the problem.
I have requested the supplier of the original PDF to create another with
no proprietary information, e.g. "hello world", and to describe the
steps they took to create the file. With that info and a test case,
maybe someone will see what the issue is.
-Paul
mkl wrote:
> 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.
------------------------------------------------------------------------------
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/