Hi Paulo ,
Thanks for the quick response. Are there some examples of HTMLWorker in use?
I was able to get the example I gave to work following what you said, but
something like the following still bunches up when there is a <p> tag that
should wrap to the next line. My code is below too.
<html>
<head>
</head>
<body>
<p style="margin-top: 0">
TERMS AND CONDITIONS
</p>
<p style="margin-top: 0">
THIS CONTRACT LIMITS LIABILITY
</p>
<p style="margin-top: 0">
</p>
<p style="margin-top: 0">
It is agreed by all that this inspection is to be performed according to
the following terms and conditions:
</p>
<p style="margin-top: 0">
</p>
<p style="margin-top: 0">
1. HICS Inc. will provide the Client a limited-time visual inspection of
the following readily accessible and visible pertinent, major elements
existing in the structure on the date of inspection
</p>
</body>
</html>
My code:
// Store the html in a string
String htmlText =
jtpSource.getDocument().getText(0,jtpSource.getDocument().getLength());
// Create a reader to pass into the html parser
StringReader strReader = new StringReader(htmlText);
com.lowagie.text.Document document =
new com.lowagie.text.Document(PageSize.LETTER);
com.lowagie.text.html.simpleparser.StyleSheet style = new
com.lowagie.text.html.simpleparser.StyleSheet();
style.loadTagStyle("body", "leading", "16,0");
try {
PdfWriter.getInstance(document, new FileOutputStream("newContract.pdf"));
document.open();
ArrayList p = HTMLWorker.parseToList(strReader, style);
for (int k = 0; k < p.size(); ++k){
document.add((com.lowagie.text.Element)p.get(k));
}
document.close();
} catch (Exception e) {
e.printStackTrace();
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/