This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create a Pdf file using Java

 
mahadevan raja
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i had already posted a query regarding how to print the contents,but in vain no reply,
can anybody tell me is there any class so as to create a pdf file and methods used to write into the pdf file.
IOStreams,do create a pdf file,but me not able to open the pdf file.
I saw a PdfWriter class,but not in sun specifications
so anyone plz help me how to create and write to a pdf file.
thanx in advance.
 
Frank Daly
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following article from javaworld might help you.
http://www.javaworld.com/javaworld/jw-10-2000/jw-1020-print.html?
However you can also generate pdf files using xml, xsl:fo and cocoon which is a servlet available from apache.
Frank
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another related option is to use the FOP from
Apache. It is the same code that Cocoon uses
to generate PDF output. But if you do not need
all of the functionality of Cocoon, using just
FOP might be a solution.
There is a release candidate for FOP available
at the apache site,
http://xml.apache.org/dist/fop
for download. I have been using it for a project
that really does not require all of Cocoon.
HTH,
Joe
 
senthil narayan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of using coocon to generate i think the foll is easy.
go to www.lowagie.com.
Tool name is :itext.
It's easy to generate pdf using this tool.
 
Sergio Glez
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! That class that you say (PdfWriter) is a part of a tool called StyleReport.
StyleReport is a reporter tool that can generate PDF, excel or HTML files.
It isn�t part of sun classes. You must by the StileReport in the next link:
http://www.inetsoftcorp.com
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17995
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also there's gnujpdf (formerly retepPDF) on sourceforge.net. It mimics the Java printing subsystem. It does OK for lightweight printing requirements, though intense graphics may be beyond it.
BTW There's a pitfall in printing PDF's. If you don't set the Content-length header to the size of the generated PDF, some versions of Netscape won't be able to display it properly.
Unfortunately, since the size of a PDF isn't easy to determine in advance, this has forced me to write the PDF to a temporary file just to get its length, output the HTTP headers, then spool out the temp file to the HTTP output stream.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic