Generating PDF

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
axel
Posts: 21
Joined: Fri Aug 10, 2007 12:37 pm

Generating PDF

Post by axel » Wed Sep 12, 2007 11:07 am

Dear all,

I have integrated some charts in a JSP file with DisplayChart servlet. This works fine.

Now I would like to convert these charts into PDF. I have created a servlet to do this. My problem is that I would like to indicate to this servlet to use the charts previously generated for the display in the jsp (and that are stored in the temp directory of Tomcat), and I don't know how to do this.
Of course if I indicate the full path C:\Programs\.....\Tomcat\temp it works, but it's won't work for remote users.

The other solution is to build again the chart in the servlet that generates the PDF, but I think it's a pity to do twice the same job, it makes the program slower...

I am trying to solve this since many days without success... please help me !! :D

Many many thanks in advance !

Axel

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Wed Sep 12, 2007 11:21 am

I wouldn't do this, if I were you. PDF is a Vector-Image format, and so you can render high-quality vector-image charts in the PDF (which look nice even if you zoom in with 1600%).

If you reuse the pixel-image charts you generated in the JSP, then the PDF will not contain vector-images and a print-out of these PDFs will result in very ugly low-res images on paper.

So no, you are not doing the Job twice - as you generate two completely different outputs for two completely different scenarios.
Of course if I indicate the full path C:\Programs\.....\Tomcat\temp it works, but it's won't work for remote users.
And why shouldnt this work for remote users? The servlet and the JSP page are executed on the server, not on the client. So both have access to the same temp-directory. However, this wont work in a clustered environment, and in most cases generating temporary files is a bad practice anyway.

Have fun,
said Thomas

axel
Posts: 21
Joined: Fri Aug 10, 2007 12:37 pm

Post by axel » Wed Sep 12, 2007 12:08 pm

Thanks for your answer !
It's very interesting. I didn't think to the quality of the PDF, and you raise an important point.
So I will probably follow your advice.

Concerning the URL C:\....., I thought the servlet would interprete it as the hard drive of the remote user....

Locked