This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

how to convert jsp form to pdf file

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi experts, I am trying to convert my jsp/html form to pdf once a button is clicked. how do I do that???
sometimes my jsp form has logo with the form , does that affect conversion

is there any program can do that for me , please help me urgently

thanks a lot

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the iText library to create PDFs. If the HTML page consists of CSS-styled XHTML, then the FlyingSaucer library is also an option.
 
alsoumahi alBatal
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:You can use the iText library to create PDFs. If the HTML page consists of CSS-styled XHTML, then the FlyingSaucer library is also an option.


thanks for reply , I don't know how to use FlyingSaucer library , could you please just an example of it .

I have found three examples of conversion but still could work for me the programs , once I open the pdf file. what shall I do??
these are the links
http://www.java2s.com/Tutorial/Java/0419__PDF/ParsingHtml.htm
http://www.java2s.com/Tutorial/Java/0419__PDF/HtmlParserfromiText.htm
http://www.java2s.com/Tutorial/Java/0419__PDF/ParsingHtmlSnippets.htm

and aonther example is below


I have error here :
pdfDocument.add(new Paragraph(org.apache.commons.io.FileUtils.readFileToString(file)));

error is :
readFileToString(java.io.File,java.lang.String) in org.apache.commons.io.FileUtils cannot be applied to (java.io.File)

what is the solution ?? , I am using commons-io-2.0.1.jar for it. But still error available.

thanks a lot
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I don't know how to use FlyingSaucer library , could you please just an example of it .


Your first stop for information should always be the home page. The FlyingSaucer site links to a couple of introductory articles, and has a user guide available for download.

error is : readFileToString(java.io.File,java.lang.String) in org.apache.commons.io.FileUtils cannot be applied to (java.io.File)


Not sure what's happening, the code compiles fine for me when linked against iText 2.1.7 and Commons IO 2.0.1 (after fixing the missing import of the Rectangle class)
 
alsoumahi alBatal
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf Dittmer
I got my problem I was useing two common jars together the new and the old one , so removing the old solve the problem , but I discoved that the pdf file is only the source
code of my html page. That is not what I am looking for , Basically I am trying to generate pdf file once use clicks a print button. User will fill form first on page , then when user
clicks print , all user information will be inserted in pdf as form so it can be printed then .what shall I do !!!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

what shall I do !!!


Please restrict yourself to single punctuation signs; it's sufficient. What's more, question are ended with question marks, not exclamation marks.

You can submit the form to the server, create the PDF there using iText, and then either a) stream the PDF as response back to the client, or b) store it on the server and include a link to it in the response page.
 
And then the flying monkeys attacked. My only defense was this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic