problem positioning chart when exporting it to pdf

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Luke

problem positioning chart when exporting it to pdf

Post by Luke » Mon Oct 07, 2002 5:54 am

Sample from documentation works fine, but I need to be able to position chart in pdf. In given example chart is in middle of page and I can change horizontal position but not vertical. In addition when I print table data inside the same pdf it always appears on the before chart if they are on the same page (I need my data to be after the chart).

I would appreciate any help...

Regards
Luke

Rich Unger

Re: problem positioning chart when exporting it to pdf

Post by Rich Unger » Mon Oct 07, 2002 7:15 pm

I used a technique different from what's in the jfreechart documentation with respect to iText. I used the com.lowagie.text.Image object. That way, you can use the "simple" iText API instead of the "advanced" one:

java.awt.Image awtImage = myJFreeChart.createBufferedImage(width, height);
com.lowagie.text.Image img = com.lowagie.text.Image.getInstance(awtImage, null);

// to make 150dpi (for printing), take 72dpi/150 = 48%
result.scalePercent(48);

Now you should be able to take that image and add it to document objects or table cells in whichever alignment suits you.

Cheers,
Rich

Rich Unger

Re: problem positioning chart when exporting it to pdf

Post by Rich Unger » Mon Oct 07, 2002 7:16 pm

oops. :s/result/img

Luke

Re: problem positioning chart when exporting it to pdf

Post by Luke » Mon Oct 07, 2002 8:50 pm

Thanks

It works fine.

Regards
Luke

Locked