1
votes

Why do I get different results when I use MoveText vs SetFixedPosition? I use the same x and y value but they print on the page in different location. If I use canvasPage.BeginText can it be formatted to use a width and word wrap

canvasPage.BeginText()    
.SetFontAndSize(PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD), 21)
.MoveText(X,Y)


Paragraph p = new Paragraph()
.Add(_disclaimer)
.SetFixedPosition(X,Y, canvasPage.W)
.SetFont(PdfFontFactory.CreateFont(StandardFonts.HELVETICA))
.SetFontColor(ColorConstants.BLACK)
.SetFontSize(12)
.SetTextAlignment(TextAlignment.LEFT);
1
With MoveText you set the coordinates of the start of the baseline of the text you draw. With SetFixedPosition you set the lower left corner of the rectangle in which the paragraph is rendered. These are different positions, depending on details like paragraph margins or leading and font descend they can differ considerably. - mkl

1 Answers

1
votes

The locations between the cases when you add text onto the canvas manually with low-level operations versus the case when you use high-level layout Paragraph objects will be different because Paragraph is responsible for multi-line layout and adds necessary margins / spacings for the text to look nice and not overlap with other content. The locations are still different only by a minor offset.

You cannot combine low-level beginText operation with high-level layout requirements (wrapping text across lines etc) - this is the responsibility of layout's Paragraph.