The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 Generating PDFs for Fun and Profit with Flying Saucer and iText
Subject:  Problem with DirectXML example
Date:  2008-02-29 14:41:32
From:  robmoore


I've found an issue in the case where the the xml file is not in a subdirectory (such as samples) but rather is at the same directory (aka user.dir). So when I create the File object with simply "weather.xml" (rather than "samples/weather.xml") an exception is thrown: org.xhtmlrenderer.util.XRRuntimeException: IOException on parsing style seet from a Reader; don't know the URI.

This error is triggered by the fact that in ITextRenderer.setDocument() the call to file.getParentFile() returns null. The code checks for that and substitutes an empty string for the value passed into setDocument(). The empty string does not appear to be resolved correctly by the underlying code (NaiveUserAgent seems to have trouble resolving empty string properly when it comes to processing the css file). One possible solution would be for ITextRenderer to call file.getAbsoluteFile().getParentFile().toURI().toURL().toExternalForm() instead (since it will return a non-null value that is equivalent to what would be returned if the parent had been set in the file object).

For now, I'll just used new File(".", inputFile).

Thanks for the article!

Rob

 Feed java.net RSS Feeds