Vlad Romascanu,

Vlad Romascanu wrote:
> Trying to digitally sign a PDF; I get the following when attempting to
> close the output file:
> 
> java.lang.ClassCastException: com.itextpdf.text.pdf.PdfDictionary cannot
> be cast to com.itextpdf.text.pdf.PRIndirectReference
>         at
> com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:209)
>         ...
> 
> This seems to happen specifically with PDFs generated by PDFCreator (on
> Windows.)  See attachments for a few small samples which exhibit the
> problem.

PdfStamperImp.java:209 is:

PRIndirectReference iInfo =
(PRIndirectReference)reader.getTrailer().get(PdfName.INFO);

Thus we have to inspect the trailer of your document, e.g. of 1_50.pdf:

trailer
<</Info <</Info <</Producer (Tailor Made Software 
i...@tailormade.com)/Title (From AutoCAD drawing
"samples/1_50.dwg")>>>>/Root 2 0 R/Size 13>> 

This is broken in two ways. First of all the /Info value (if present) shall
be an indirect reference, cf. ISO 32000-1:2008 Table 15:

- Info
- dictionary
- (Optional; shall be an indirect reference) The document’s information
dictionary (see 14.3.3, "Document Information Dictionary").

In your case it's a direct object, though.

Second, the information dictionary should immediately contain the document
information, not inside an inner dictionary.

Regards,   Michael.

PS: Of course a ClassCastException is not a nice way of iText to react to
such a situation... ;)
-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/ClassCastException-in-PdfStamperImp-java-tp2232601p2232714.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/

Reply via email to