| Issue 181: | PDF export can not resolve remote dtd file xhtml1-transitional.dtd | |
| 2 people starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. Create a table with JMesa from a Controller
2. Try to Export to PDF using :
PdfView pdfView = (PdfView)tableFacade.getView();
pdfView.setCssLocation("/web/css/jmesa-pdf.css");
3. The App Server should be behind a Proxy that requeries validation or
shouldnt have Internet access at all.
What is the expected output? What do you see instead?
Instead of generating the PDF export file renderer tries to get the DTD's
from http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd instead of a
local copy,when behind a Proxy that requeries validation it can“t get the
dtd and returns a:
java.net.UnknownHostException: www.w3.org
What version of the product are you using? On what operating system?
jmesa 2.3.4 / Windows XP Professional / Glassfish
Please provide any additional information below.
I solved this issue using one of these two posible options, you might
consider integrate the second one to your code base.
I) Get a local copy of the DTD files in a local directory:
xhtml1-transitional.dtd
xhtml-lat1.ent
xhtml-special.ent
xhtml-symbol.ent
configure Jmesa to use these files instead of the remote files in
jmesa.properties with the following line:
pdf.doctype=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"../webapps/jmesa/web-inf/dtds/xhtml1-transitional.dtd">
II) Modify org.jmesa.view.pdf.PdfViewExporter's export() function to
instruct the DocumentBuilder to use a FSEntityResolver , the resolver will
load the DTDs from core-renderer-R8pre1.jar
The changes look more or less like these:
import org.xhtmlrenderer.resource.FSEntityResolver
..
..
..
DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
FSEntityResolver er= FSEntityResolver.instance(); //These is the fix
builder.setEntityResolver(er); //These is the fix
Document doc = builder.parse(new ByteArrayInputStream(contents));
Feb 24, 2009
#1
bgo...@e1b.org
Feb 24, 2009
Actually, I think JMesa's PdfViewExporter should use xhtmlrenderer in a way it doesnt have to load the DTD's remoteley every time a document is rendered, xhtmlrenderer provides FSEntityResolver specifically for this. In that way you can avoid "W3C's Excessive Dtd Traffic" responses from W3C http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic as reported in this thread: http://markmail.org/message/pnxnv34z2dk3ml33 wich is where I did find out about FSEntityResolver
Mar 4, 2009
I missed this post...and you had so much detail too! If you are able to submit a patch I would be interested in how it works out! Building the project is fairly simple once you have groovy on your machine. https://code.google.com/p/jmesa/wiki/ProjectBuild If not I will leave this as an open issue for a future release. I put that pdf.doctype property in the preferences just in case something like this came up...
Mar 6, 2009
Here is the patch , however since I am behind a Proxy I had trouble in: -getting my svn client to download the code -getting AntBuilder and Ivy to download dependencies Both requeried custom configurations wich might be useful to others, I could prepare a small guide for "Developers behind a Proxy " to be included in the Wiki. If you are interested, let me know.
Mar 7, 2009
This looks great! What should the default doctype in the preferences be set to? Right now it looks like this: pdf.doctype=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> If you made a "Developers behind a Proxy" guide I would get that on the wiki right away. I am sure many other developers could take advantage of that information.
Mar 7, 2009
(No comment was entered for this change.)
Status:
Started
Mar 11, 2009
It's ok if the default value is pdf.doctype=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> because if the patch works as expected, the dtds would be loaded from core-renderer-R8pre1.jar anyway. I am attaching the "Behind a Proxy" configurations as a txt file,
Mar 11, 2009
Sounds good! I will check in the patch tonight when I get home. I will also start posting your documentation on the wiki. I have another example I want to post as well. I should be doing a release within a week or so. I am waiting to hear back from another developer about some other changes.
Mar 11, 2009
I have the patch checked in. I also have your documentation on the wiki. Feel free to let me know if you have any changes to it... https://code.google.com/p/jmesa/wiki/ProjectBuildBehindProxy I also have that other code from the other developer I was waiting for now so expect a build in the next few days!
Apr 5, 2009
Part of the 2.4.2 release!
Status:
Done
Aug 11, 2009
Hi,
for me to come into working state after above all changes in PdfViewExporter.java
required one more change, which is comment the line "
System.setProperty("xr.load.xml-reader", "org.ccil.cowan.tagsoup.Parser");" of export
method.
|