Hi,
I try to keep paragraph together with addElement() method. But I don't know
why, it doesn't work.
Could you help me please ?
This is a part of my code :
/** Accumulates paragraphs for the sections (and its subsections) in
this.doc
* @throws IOException */
private void recursiveWalk(Section currentSection) throws
DocumentException, IOException{
Chunk pTitle = createTitleChunk(currentSection); // Create
Title Style
addTitle(pTitle); //Add Title
addBody(currentSection); //Add Body
// Childs (recursive call)
for (Section sSection : currentSection.getSubSections()) {
recursiveWalk(sSection);
}
}
private void addBody(Section currentSection) throws IOException,
DocumentException {
String body = currentSection.getBody();
CourseTextFormatter sectionFormatter = new
CourseTextFormatter("", body);
StyleSheet styleBody = new StyleSheet();
styleBody.loadStyle("p", "size", "8"); //Style of the body
List<Element> bodyElements; //Create List with the paragraph
bodyElements = HTMLWorker.parseToList(new
StringReader(sectionFormatter.format()), styleBody); //Format text and apply
style
for (Element element : bodyElements){
this.ct.addElement(element);
this.ct.go();
while (true){
this.status = this.ct.go();
if (!ColumnText.hasMoreText(this.status)){
break;
}
this.doc.newPage();
this.ct.setSimpleColumn(36, 36,
PageSize.A4.getWidth() - 36,
PageSize.A4.getHeight() - 36, 18, Element.ALIGN_LEFT);
}
}
}
private void addTitle(Chunk pTitle) throws DocumentException {
this.ct.addElement(new Paragraph("\n"));
this.ct.addElement(new Paragraph(pTitle));
this.ct.addElement(new Paragraph("\n"));
this.ct.go();
}
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/Do-not-have-orphan-with-addElement-tp2993271p2993271.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
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