Hi,

I am having a problem with some PDFs containing attachments (generally a 
JPEG image of the first page of the PDF).

This is my code.

...
PdfReader reader = new PdfReader(pdfInputStream);
int endPage = reader.getNumberOfPages();

for (int currentPage = 1; currentPage <= endPage; currentPage++) {
Document document = new 
Document(reader.getPageSizeWithRotation(currentPage));
PdfSmartCopy copy = new PdfSmartCopy(document, 
getSinglePdfOutputStream(currentPage));
copy.setFullCompression();
document.open();
PdfImportedPage page = copy.getImportedPage(reader, currentPage);
copy.addPage(page);
document.close();
}
...

I am getting a runtime exception thrown by copy.addPage(page). The stack 
trace is as follows.

Caused by: java.lang.ClassCastException: com.lowagie.text.pdf.PdfNumber
    at com.lowagie.text.pdf.PdfCopy.copyDictionary(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfSmartCopy.copyIndirect(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyStream(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfSmartCopy.copyIndirect(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyDictionary(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyDictionary(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyDictionary(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfSmartCopy.copyIndirect(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyArray(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfSmartCopy.copyIndirect(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyObject(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.copyDictionary(Unknown Source)
    at com.lowagie.text.pdf.PdfCopy.addPage(Unknown Source)

Are there any know issues with attachments, or has anyone had similar 
experiences?

I am using itext 2.0.4.

Will.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to