Jump to content
We've recently updated our Privacy Statement, available here ×

Printing PDF with JFreeChart generated charts


Recommended Posts

By: o_kevin_o - o_kevin_o

Printing PDF with JFreeChart generated charts

2005-04-06 16:44

When I use Adobe Reader to print PDF containing JFreeChart charts on a PostScript printer, the charts come out red/black.

 

Why is this happening? Does anyone know how to work around this problem?

 

BTW, I have tried JCharts, but the image quality is very poor.

 

 

By: o_kevin_o - o_kevin_o

problem fixed

2005-04-10 02:45

I think JasperReports have a huge potential, but it seems that not many developer are using it in an enterprise environment at the moment because I don't other people writing about the problem I reported. I figured out what the problem is, and for those who will have the same problem, here's my solution:

 

In the iText's com.lowagie.text.Chunk class, replace

 

public Chunk(Image image, float offsetX, float offsetY) {

this(OBJECT_REPLACEMENT_CHARACTER, new Font());

 

with

 

public Chunk(Image image, float offsetX, float offsetY) {

this("", new Font());

 

 

 

By: Paulo Soares - psoares33

RE: problem fixed

2005-04-10 03:07

I don't see why that would change anything, the character is only used as a token in bidi reordering. Your problem was certainly elswhere or you've found a bug in iText. Please post the before/after pdf.

 

 

By: o_kevin_o - o_kevin_o

PDF files

2005-04-11 16:34

Thank you for responding to my posting.

 

The pdf files are too big to post here; but you can download the before-PDF from the http://jasperreports.sourceforge.net/ Just get the latest version (0.6.6) and open demosamplesjfreechartbuildreportsJFreeChartReport.pdf file.

 

To get the after-PDF, make the change and run the JasperReports with the new iText jar file.

 

When you print the after-PDF on a postscript printer, the black(red) box is gone.

 

 

By: o_kevin_o - o_kevin_o

more problem

2005-04-12 11:13

When I make the change, the GIF images that used to be on the report disappears. :-(

 

 

By: o_kevin_o - o_kevin_o

solution

2005-04-15 12:32

I finally had chance to work on this problem, and it's working for me. In case the solution is not obvious from the previous posting, here's how:

 

1. In the iText(v.1.2)'s com.lowagie.text.Chunk class, add the following constructor:

 

public Chunk(Image image, float offsetX, float offsetY, String objectReplacementCharacter) {

this(objectReplacementCharacter, new Font());

Image copyImage = Image.getInstance(image);

copyImage.setAbsolutePosition(Float.NaN, Float.NaN);

setAttribute(IMAGE, new Object[]{copyImage, new Float(offsetX), new Float(offsetY), new Boolean(false)});

}

 

2. Compile and create jar file for the iText

 

3. In the JasperReports(v.0.6.5)'s JRPdfExporter class, modify the line 1139 as follows:

 

chunk = new Chunk(image, 0, 0, "");

^^^^

 

In case the line numbers are different, it's located in the else block for

 

if (renderer.getType() == JRRenderable.TYPE_IMAGE)

 

4. Using the new iText jar file, compile and build jar file for JasperReport.

 

 

Hope this information helps the future developers.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...