This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes PDF creation using iTEXT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "PDF creation using iTEXT" Watch "PDF creation using iTEXT" New topic
Author

PDF creation using iTEXT

Daniel Sagayaraj
Ranch Hand

Joined: Mar 15, 2010
Posts: 32
Dear Friends..
I am using iTEXT to convert xhtml into pdf in a web application.i am getting the following error.I tried my level best to spot the cause of the error.But could not do it.

The Code:


String inputFile = "D://Data_Local//xml//docs//testXHTML.xml";
String url = new File(inputFile).toURI().toURL().toString();
String outputFile = "D://Data_Local//xml//docs//firstdoc.pdf";
OutputStream os = new FileOutputStream(outputFile);
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);
os.close();


Error:

Exception occured While Logging In : org.xhtmlrenderer.util.XRRuntimeException: Failed on configuring SAX to DOM transformer.


This same java code works fine when it is used in java application but throws this exception when used in web application....


Thank You.....


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41148
    
  45
So you're actually using the FlyingSaucer library, not iText.

Are you certain that this: "new File(inputFile).toURI().toURL().toString()" produces something sensible?


Ping & DNS - my free Android networking tools app
Daniel Sagayaraj
Ranch Hand

Joined: Mar 15, 2010
Posts: 32
Ulf Dittmer wrote:So you're actually using the FlyingSaucer library, not iText.

Are you certain that this: "new File(inputFile).toURI().toURL().toString()" produces something sensible?



ya checked that dear...

it returns--->file:/D:/Data_Local/xml/docs/testXHTML.xml

Daniel Sagayaraj
Ranch Hand

Joined: Mar 15, 2010
Posts: 32
Yamuna Daniel wrote:Dear Friends..
I am using iTEXT to convert xhtml into pdf in a web application.i am getting the following error.I tried my level best to spot the cause of the error.But could not do it.

The Code:


String inputFile = "D://Data_Local//xml//docs//testXHTML.xml";
String url = new File(inputFile).toURI().toURL().toString();
String outputFile = "D://Data_Local//xml//docs//firstdoc.pdf";
OutputStream os = new FileOutputStream(outputFile);
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);
os.close();


Error:

Exception occured While Logging In : org.xhtmlrenderer.util.XRRuntimeException: Failed on configuring SAX to DOM transformer.


This same java code works fine when it is used in java application but throws this exception when used in web application....


Thank You.....




Dear Friends...

The same code works fine with both java application and web application.The problem is...
it doesn't work in one particular project...



Daniel Sagayaraj
Ranch Hand

Joined: Mar 15, 2010
Posts: 32
Dear Friends...
I was not able to fine the cause of the error but found the alternative to the achieve the requirement..

It works when i pass org.w3c.dom.Document instead of passing a file URL ....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PDF creation using iTEXT
 
Similar Threads
flying saucer not converting cellspacing html property properly into pdf
flying saucer not identifying   of html
Hi All
Rendering PDF in browser using Flying Saucer
How to save a webpage as PDF ?