Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PDF creation using iTEXT

 
Daniel Sagayaraj
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you're actually using the FlyingSaucer library, not iText.

Are you certain that this: "new File(inputFile).toURI().toURL().toString()" produces something sensible?
 
Daniel Sagayaraj
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic