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?
From posting above I'm using Firefox ver 188.8.131.52. I ran the itext demo from CVS (today) and I get the same issue. Running in i.e. works fine.
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:
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);
ResponseWriter 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 !
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
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.
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.
<f:view contentType="text/html"/> works for Facelet templates, even if your XML validator in your IDE says it doesn't.
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...)
It's a Facelets feature, I think. Google for "Facelets content-type FAQ" and it'll turn up.