Hi,

I tried to convert a HTML page with ordered list and some div tags with
itextpdf, but it does not seem to work. I created the following simple
ordered list structure in HTML to demonstrate the problem:


<!DOCTYPE html>

<html>

<head>

  <title>Insert title here</title>

</head>

<body>

  <!-- <div> -->

  <ol>

    <li>A

      <ol>

        <li>AA</li>

        <li>AB</li>

        <li>AC

          <ul>

            <li>ACA</li>

            <li>ACB</li>

          </ul>

        </li>

        <li>AD

          <ul>

            <li>ADA</li>

            <li>ADB</li>

          </ul>

        </li>

      </ol>

    </li>

  </ol>

  <!-- </div> -->

</body>

</html>

It works fine so far, and I get the correct, well formatted PDF. When,
however, I remove the comment around the div tag, it does not work  any
more. I get all element of the ordered list in a single line, in the result
PDF file like this:


A AAABAC ACAACBAD ADAADB

My method for the conversion looks like this:


private void convertHtmlToPdf(String htmlFilePath, String
generatedPdfFilePath) throws IOException, FileNotFoundException,
DocumentException {

    String fileContent = FileUtils.readFileToString(new File(htmlFilePath));

    OutputStream file = new FileOutputStream(new
File(generatedPdfFilePath));

    Document document = new Document();

    PdfWriter writer = PdfWriter.getInstance(document, file);

    document.open();

    InputStream is = new ByteArrayInputStream(fileContent.getBytes());

    XMLWorkerHelper.getInstance().parseXHtml(writer, document, is);

    document.close();

    file.close();

}


So it is the simplest conversion code. I don't use any CSS, or insert any
pictures. In my real code however, I do need to use CSS for the conversion,
and the formatting is defined via div elements. So I can not simple remove
all the div-s to get the conversion working. Is it a bug, in itextpdf, or I
miss something? Has anybody any idea for a workaround, to deal with this
problem?

I am using the actually latest (5.5.6) version of itextpdf.
------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical & virtual servers, alerts via email & sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to