I have an issue with the itext library that can be described as follow :
I want to put a vertical space between two paragraphs by using the spacingBefore property on the second paragraph.
The problem is that from a certain value of space units (by default point unit), itext causes the second paragraph to be displayed on a new page even though there is obviously enough space to put the 2 paragraphs on the same page.
This code illustrates this situation :
public static void main(String[] args) throws Exception {
Document document = new Document();
OutputStream result = new FileOutputStream("output.pdf");
PdfWriter.getInstance(document, result);
document.open();
Paragraph paragraph1 = new Paragraph("First paragraph");
Paragraph paragraph2 = new Paragraph("Second paragraph");
//380 causes the new page...
paragraph2.setSpacingBefore(380f);
//...whereas 370 does not
// paragraph2.setSpacingBefore(370f);
document.add(paragraph1);
document.add(paragraph2);
document.close();
}
Does someone hava an explication of this strange behaviour?
Thanks in advance