pier luigi zanotti
2012-07-06 06:58:42 UTC
I'm a bit confused about newline handling in chunks text. The following
code:
Paragraph para = new Paragraph();
para.add(new Chunk(" A"));
para.add(new Chunk("\n B"));
para.add(new Chunk("\n C"));
document.add(para);
add a paragraph of 3 lines, where the first line in the resulting pdf
document is slightly shifted to the right, while I was expecting that
the lines began at the same exact horizontal position. Note that every
letter "A", "B", "C" is preceded by two space char.
If I use a newline also in the first Chunk, the three lines are
perfectly horizontally aligned in the output document:
Paragraph para = new Paragraph();
para.add(new Chunk("\n A"));
para.add(new Chunk("\n B"));
para.add(new Chunk("\n C"));
document.add(para);
So the question is: why the presence of a newline character on a chunk
text affect the horizontal position of the text itself?
The version of iText I'm using is 5.2.1 .
code:
Paragraph para = new Paragraph();
para.add(new Chunk(" A"));
para.add(new Chunk("\n B"));
para.add(new Chunk("\n C"));
document.add(para);
add a paragraph of 3 lines, where the first line in the resulting pdf
document is slightly shifted to the right, while I was expecting that
the lines began at the same exact horizontal position. Note that every
letter "A", "B", "C" is preceded by two space char.
If I use a newline also in the first Chunk, the three lines are
perfectly horizontally aligned in the output document:
Paragraph para = new Paragraph();
para.add(new Chunk("\n A"));
para.add(new Chunk("\n B"));
para.add(new Chunk("\n C"));
document.add(para);
So the question is: why the presence of a newline character on a chunk
text affect the horizontal position of the text itself?
The version of iText I'm using is 5.2.1 .