How to define the space that a string will occupy in C # / PDFsharp

1

I would like to define how far the string will take up space. the values (200,50) refer to the beginning of the text x = 200 y = 50, the other 2 values I do not know for what it is, even doing some tests.

textFormatter.DrawString("texto texto texto texto", fontTitulo,
PdfSharp.Drawing.XBrushes.Black,
new PdfSharp.Drawing.XRect(200,50, 10, 50));
    
asked by anonymous 27.06.2018 / 15:52

1 answer

0

As we can see in the PdfSharp code a>, the constructor is defined as: public XRect(double x, double y, double width, double height) .

Thinking about the two axes, X (Horizontal from left to right) and Y (Vertical from top to bottom) we have a point X, Y which is the starting point of the rectangle.

Then we have the value W (Width / Width) and H (Height / Height) which are respectively the width and height of the rectangle.

Example:

FromwhatIsawagaininthe PdfSharp code , this parameter is only used to calculate position and alignment of text.

And for you to know what size the string will occupy, you use the MeasureString " that you inform you the text, and the font and a% object is returned with the width and height of the text.

    
28.06.2018 / 20:47