Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to generate pdf from xhtml page dynamically using itext+flying saucer with java
    primarykey
    data
    text
    <p>I am using iText+flying saucer for the first time with xhtml pages using JSF 2.0 for simple registration form with regular input fields like firstName,lastName,phone number etc.Once user enters all the data and click on <strong>"NEXT</strong>" button I have to convert this XHTML page with User data into pdf.How can i exactly get the source HTML of this page with all the styles included in the page and convert it to pdf.Currently I am tying like this.</p> <pre><code>public void createPDF() { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); HttpSession session = (HttpSession) externalContext.getSession(true); String url = "http://localhost:8080/MyPROJECT/faces/page1.xhtml;JSESSIONID=" + session.getId(); try { ITextRenderer renderer = new ITextRenderer(); renderer.setDocument(url); renderer.layout(); HttpServletResponse response = (HttpServletResponse) externalContext.getResponse(); response.reset(); response.setContentType("application/pdf"); response.setHeader("Content-Disposition","C://user//first.pdf"); OutputStream browserStream = response.getOutputStream(); renderer.createPDF(browserStream); browserStream.close(); session.invalidate(); } catch (Exception ex) { ex.printStackTrace(); } facesContext.responseComplete(); } </code></pre> <p>But it's throwing me this exception.</p> <pre><code>ERROR: 'The string "--" is not permitted within comments.' org.xhtmlrenderer.util.XRRuntimeException: Can't load the XML resource (using TRaX transformer). org.xml.sax.SAXParseException: The string "--" is not permitted within comments. </code></pre> <p>Is this the right way to get my page using above URL.Does that URL get my page with User Data on click of NEXT Button and convert it pdf or am I trying with wrong code.Please help me. Examples appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload