BlueLettuce16
BlueLettuce16

Reputation: 2103

flaying saucer org.xml.sax.SAXParseException The declaration for the entity HTML.Version must end with >

I have xhtml file with: which on http://validator.w3.org/ gives me result: This document was successfully checked as HTML 4.01 Transitional!

I am parsing it with the following code: OutputStream os = null;

    ITextRenderer renderer = new ITextRenderer();

    os = new FileOutputStream(new File("example.pdf"));
    BufferedReader reader1 = new BufferedReader(new FileReader("x:\\workspace\\Test.html"));

    StringBuilder sb = new StringBuilder();
    String line = null;
    while ((line = reader1.readLine()) != null) {
        sb.append(line);
    }

    reader1.close();

    String str = sb.toString();

    renderer.setDocumentFromString(str);
    renderer.layout();
    renderer.createPDF(os);

    os.close();

and I'm getting error as described in title. Do you know how to fix this issue?

Upvotes: 1

Views: 2662

Answers (1)

Uwe Plonus
Uwe Plonus

Reputation: 9974

You forgot a closing bracket (>) in your HTML page.

Therefore it is no XHTML page but simply a HTML4 page. The validator you named is only useable to validate HTML4 and not XHTML.

HTML4 lets you do things that are forbidden in XML (and XHTML), e.g. in HTML the following would be legal:

<br

Upvotes: 1

Related Questions