Subject: Rules regarding PdfTextAlignment when wrapping text
Date: 2014-07-30 06:26:20
From: Yaakov Ellis
Source: rules-regarding-pdftextalignment-wrapping-text
----------------------------------------------------------------------

I have noticed that when running a Graphics.DrawString command, the drawing behavior is inconsistent depending on whether or not the text is wrapping.

If no wrapping is being used, then the X coordinate that is provided is taken to be the right margin of the text, and the text is drawn such that its right-most edge is aligned with the x-coordinate. This is the case even when a width or rectangle is provided (in which cases, I would have expected the x to be the left-margin, with the right margin and alignment dictated by the width/right-side-of-rectangle).

I did not see this documented anywhere, but was able to figure it out by trial and error.

However, when the PdfStringFormat property being passed into DrawString also contains a Wrapping value (Word or WordOnly), it seems that right alignment is totally ignored (seems to be a bug).

Am I understanding the current functionality properly? Is this documented anywhere?

---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index