Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8681617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:33:26+00:00 2026-06-12T21:33:26+00:00

I am using iText+flying saucer for the first time with xhtml pages using JSF

  • 0

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 “NEXT” 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.

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();
}

But it’s throwing me this exception.

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.

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:33:27+00:00Added an answer on June 12, 2026 at 9:33 pm

    This exceptions sounds more like a problem in the (x)html of your website. Is there something like <!-- some -- comments --> in your html?

    Flying Saucer throws this exception because there’s a -- somewhere in a comment block. Check this up and if possible try it without -- between <!-- and -->.

    However, since FS will fail on every little misstake in (X)HTML / XML (as noted in the readme), its often a good idea to use a HTML Cleaner before processing a website.

    Here are two examples:

    • JSoup
    • HtmlCleaner
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert strict XHTML to PDF using flying saucer and iText. I've
I'm using xhtmlrenderer (Also known as Flying Saucer) with iText to convert HTML to
I'm compiling a PDF using iText and Flying Saucer, and unfortunately, I can't seem
I'm creating a PDF using Flying Saucer (which dumps out CSS/HTML to iText to
I am using Flying Saucer with IText in order to generate PDFs from an
I'm using a custom truetype font in a pdf generated by flying saucer xhtmlrenderer.
Using iText, I am wanting to open a PDF file, add some more pages
I am using iText to populate a pdf form using data from our database.
I'm using flying saucer xhtmlrenderer for building pdf documents. Everything worked fine until now
I'm using iText in Java to select a few pages out of a big

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.