-
1. Re: issue with itext pdf generation and JSF RI
jdestef Apr 26, 2007 10:43 AM (in response to borisrodman)Hi,
Are you using FireFox? I have a similar issue. The application can display the pdf fine when using internet explorer but I get the same message you do with FireFox. At least in my case it looks like FireFox thinks the response is an XML doc?
Tx -
2. Re: issue with itext pdf generation and JSF RI
jdestef Apr 26, 2007 10:49 AM (in response to borisrodman)Hi,
From posting above I'm using Firefox ver 2.0.0.3. I ran the itext demo from CVS (today) and I get the same issue. Running in i.e. works fine.
Tx -
3. Re: issue with itext pdf generation and JSF RI
borisrodman Apr 26, 2007 11:37 AM (in response to borisrodman)Hi
I managed to find the issue:
in the UIdocument class seam forward to a page that redirect to the PDF document:
the page rendered has no Doctype specified and the MIME return type is set to XML/Application (or something similar) therefore firefox doesn't know what to do with it.
A agree with you that it doesn't bother IE
to fix the issue you must change the class:
(jboss-seam-1.2.1.GA\src\pdf)
org.jboss.seam.pdf.ui.UIDocument to output a doctype:
in the medhod: public void encodeBegin(FacesContext context)
replace the following lines (from line 233):ResponseWriter response = context.getResponseWriter(); response.startElement("html", this); response.startElement("head", this);
byResponseWriter response = context.getResponseWriter(); response.write("<!DOCTYPE composition PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\" >"); response.startElement("html", this); response.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml", null); response.startElement("head", this);
then recompile seam using the std build file (this will also recompile jboss-seam-pdf.jar where this class ends-up)
and replace jboss-seam-pdf.jar in your project by the re-compiled jar
It SHOULD work ! (At leasts it does for me)
Also note that if you use the source code from CVS the jboss.jpg image in the itext example was corrupted last week which resulted in the PDF rendering to fail. (I don't know if this has been corrected since then)
Let me know if you have any issues ! -
4. Re: issue with itext pdf generation and JSF RI
asavitsky May 1, 2007 3:43 PM (in response to borisrodman)Have you opened a JIRA on this one? I'm still getting the same problem you described. BTW, it only shows up in RI - MyFaces 1.1.4 works fine
-
5. Re: issue with itext pdf generation and JSF RI
robjellinghaus May 1, 2007 6:14 PM (in response to borisrodman)I would expect the Seam team to have to fix this for Seam 1.3, when the RI will become the standard Seam JSF implementation. The problem is definitely that the RI more often emits a content-type of application/xhtml+xml for XHTML pages, which Firefox tries to parse as XHTML. Arguably this is just bad -- it actually breaks GWT, for instance, and XHTML 2.0 seems to be dead in the water.
In Facelets you can add a wrapper f:view tag with attribute contentType="text/html" to override this in some situations. Not sure if this will work for the itext PDF pages, but it might be worth a shot. -
6. Re: issue with itext pdf generation and JSF RI
asavitsky May 2, 2007 9:45 AM (in response to borisrodman)f:view doesn't have a contentType attribute, sorry.
And for some reason I don't have the ability to open JIRA issues. Damn.
borisrodman's suggestion works, though - one doesn't even need to recompile the whole source, just place the corrected class in the project, it will automatically take precedence for the one in Seam JAR. -
7. Re: issue with itext pdf generation and JSF RI
christian.bauer May 2, 2007 9:54 AM (in response to borisrodman)<f:view contentType="text/html"/> works for Facelet templates, even if your XML validator in your IDE says it doesn't.
-
8. Re: issue with itext pdf generation and JSF RI
asavitsky May 2, 2007 1:45 PM (in response to borisrodman)Whoa, it worked! Thanks Rob & Christian :)
(actually, it's the JSF specs that I checked for the contentType attribute - for some reason it's not listed even there...) -
9. Re: issue with itext pdf generation and JSF RI
robjellinghaus May 2, 2007 2:21 PM (in response to borisrodman)It's a Facelets feature, I think. Google for "Facelets content-type FAQ" and it'll turn up.