Reputation: 7871
I have a question about the leading of Paragraph object in Itext (I'm using version 5.2.1). This is the code:
BaseFont f = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
Font ftext = new Font(f, 12);
Paragraph ptest = new Paragraph("Line n.1\nLine n.2\nLine n.3", ftext);
Paragraph pInner = new Paragraph("This has\nleading=28", ftext);
pInner.setLeading(28f);
ptest.add(pInner);
ptest.add(new Chunk("Line n.4 (chunk)\n"));
ptest.add(new Chunk("Line n.5 (chunk)\n"));
ptest.add(new Chunk("Line n.6 (chunk)\n"));
ptest.add(new Chunk("Outer paragraph leading=" + ptest.getLeading()));
document.add(ptest);
The resulting PDF from this code is not what I'm expecting.
The outer Paragraph, ptest, has leading 18 (calculated by iText multiplying font size by 1.5); then I add a second Paragraph pInner, with leading 28 and finally I add to the first Paragraph four chunks. Since ptest has still leading 18, I'd expect that the last 4 lines would have a leading = 18, instead have a leading = 28.
Is this correct or the expected behaviour?
Upvotes: 0
Views: 163
Reputation: 4871
This is not expected behaviour.
We have improved leading processing. It will be available in the upcoming 5.4.5 release.
Upvotes: 1