java - iText: Why the last item of an unordered html bullet list is not showing on my PDF? -
i'm following itextpdf
example http://itextpdf.com/sandbox/htmlworker/htmlcontentforcell.
i'm facing problem where, whenever there bulletlist
in html-content i'm parsing elements , filling pdfcell
with, else shows fine in except last item missing. cause that?
i have following code:
// relevant code main part of class: bytearrayoutputstream baos = new bytearrayoutputstream(); document document = new document(pagesize.a4, 40, 40, 40, 40); pdfwriter writer = pdfwriter.getinstance(document, baos); document.open(); document.add(buildcontent()); document.close(); // method should provide content document. public pdfptable buildcontent() throws ioexception { infolist infolist = infolistinstance.get(); pdfptable table = new pdfptable(2); (infolistmessage message : infolistlist.getmessages()) { rendermessagemetadata(message, table); rendermessagecontent(message, table); } return table; } // method problem occurs , exception thrown in for-loop line public void rendermessagecontent( infolistmessage message, pdfptable table) throws ioexception { pdfpcell cell = new pdfpcell(); (element e : xmlworkerhelper.parsetoelementlist(message.getcontent(), null)) { cell.addelement(e); } table.addcell(cell); }
i'm quite sure related html tags, i'm lost when comes intricacies of html tags. here's example html code. i'm feeding xmlworkerhelper.parsetoelementlist html:
<html> <head></head> <body> <span>lisätty liitteet</span> <ul> <li>document2.txt.txt (23 b)</li> <li>document1.txt.txt (12 b)</li> <li>document3.txt.txt (27 b)</li> </ul> </body> </html>
and here's screenshot of cell pdf application creates:
please take @ htmlcontentforcell2. it's similar example refer to, instead of paragraphs, html consists of unordered list:
public static final string html = "<ul><li>overview line1</li>" + "<li>overview line2</li><li>overview line3</li>" + "<li>overview line4</li><li>overview line5</li></ul>";
there 5 list items in list, , when @ resulting pdf, see 5 of them:
of course, simple html, used proof of concept last item of list not disappear.
these possible reasons why not items appear:
- maybe nesting lists. deep nesting of lists isn't supported in context of tables.
- maybe there's small error in tags. instance: maybe list item missing
<li>
tag. - maybe there's content in list item special , isn't picked xml worker
for definitive answer, we'd need see html. prepare sscce based on htmlcontentforcell2?
update:
the html provided simple , valid. able reproduce problem, hence faced bug. i'll file bug report issue.
note able work around problem adding content after final </ul>
: see htmlcontentforcell3 , resulting pdf html_in_cell3.pdf. however, that's quick fix works around bug rather fixing it. bug should fixed.
Comments
Post a Comment