My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
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
Status:  Done
Owner:  ----
Closed:  Apr 2009


 
Reported by marioalb...@gmail.com, Feb 23, 2009
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
I think that this is not really a JMesa problem, but rather an infrastructure issue.
 Another solution would be to use an XML catalog file so that you can resolve those
DTDs locally.  Try searching for "xml dtd catalog" or something like that.
Feb 24, 2009
#2 marioalb...@gmail.com
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
Project Member #3 jeff.johnston.mn@gmail.com
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
#4 marioalb...@gmail.com
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.
fix-for-181.patch
808 bytes   View   Download
Mar 7, 2009
Project Member #5 jeff.johnston.mn@gmail.com
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
Project Member #6 jeff.johnston.mn@gmail.com
(No comment was entered for this change.)
Status: Started
Mar 11, 2009
#7 marioalb...@gmail.com
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,
BuildJmesaBehindAProxy.txt
2.9 KB   View   Download
Mar 11, 2009
Project Member #8 jeff.johnston.mn@gmail.com
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
Project Member #9 jeff.johnston.mn@gmail.com
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
Project Member #10 jeff.johnston.mn@gmail.com
Part of the 2.4.2 release!
Status: Done
Aug 11, 2009
#11 vikram.b...@gmail.com
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.

Powered by Google Project Hosting