Align column to right pdfsharp

Asked

Viewed 80 times

0

Good morning, I am using the pdfsharp library, and I want to line up the column for the value on the right. Could you help me, please? Follow the code below.

            graphics.DrawString(f.ENT_DAELOC, font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna, vLinha, 100, 0));
            graphics.DrawString(f.ENT_MATRIC, font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna + 50, vLinha, 100, 0));
            graphics.DrawString(f.ENT_MED_ANO_OUT, font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna + 130, vLinha, 100, 0));
            graphics.DrawString(f.ENT_RIGEM, font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna + 190, vLinha, 100, 0));
            graphics.DrawString(f.ENT_VALOR.PadLeft(18, ' '), font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna + 220, vLinha, 100, 0));
            graphics.DrawString(f.ENT_VR_MEDIDO.PadLeft(18, ' '), font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna + 320, vLinha, 100, 0));
            graphics.DrawString(f.ENT_VR_DIFERENCA.PadLeft(18, ' '), font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna + 420, vLinha, 100, 0));
            graphics.DrawString(f.ENT_REMANEJ, font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna + 520, vLinha, 100, 0));
            graphics.DrawString(f.ENT_DEBAUT, font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna + 580, vLinha, 100, 0));
            graphics.DrawString(f.ENT_CORTE, font, PdfSharp.Drawing.XBrushes.Black, new RectangleF(vColuna + 640, vLinha, 100, 0));

1 answer

1


The method DrawString has an Overload that accepts a StringFormat.

ex:

var format = new StringFormat
{
    Alignment = StringAlignment.Far,         
};

graphics.DrawString("texto", font, Brushes.Black, new RectangleF(vColuna, vLinha, 100, 0), format);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.