Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Error when stamping a JFreeChart wrapped as an
 image

victor73

2007-08-13

Replies:


Hi all!

I'm trying to add a JFree pie chart to a pdf using the PdfStamper class
without having to save the chart as an image file first. The code runs
without errors, but when I try to open the resulting output pdf, I get the
following error from Acrobat Reader (versions 7 & 8):

"There was an error processing a page. There was a problem reading this
document (18)."

I can get it to work by first saving the chart as a .png then loading it and
inserting it with the PdfStamper, but I'd rather not do it that way so I
don't have to worry about print resolution issues... Here is a simplified
code snippet of what I'm doing:


 public void stamp(PdfTemplate chartTemplate) {
    PdfReader reader = new PdfReader("/path/to/template.pdf");
    PdfStamper stamper = new PdfStamper(reader,
         new FileOutputStream("/path/to/output.pdf"));
   
    PdfContentByte over = stamper.getOverContent(1);
   
    Image image = Image.getInstance(chartTemplate);

    image.scaleAbsolute(216, 216);
    image.setAbsolutePosition(20, 80);
    over.addImage(image);
   
    stamper.close();
 }
--
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
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@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.