I am trying to get new line but if I use \n
it does not work.
Any way to have new line by adding something to string like \r\n
(which also does not work)
gfx.DrawString("Project No \n" + textBoxProjNumber.Text, fontUnder, XBrushes.Black, 230, 95);
(the example snippet shows what I've tried but does not work).
Have you tried the XTextFormatter class?
See here: http://www.pdfsharp.net/wiki/TextLayout-sample.ashx
Code snippet:
PdfDocument document = new PdfDocument(); PdfPage page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Times New Roman", 10, XFontStyle.Bold); XTextFormatter tf = new XTextFormatter(gfx); XRect rect = new XRect(40, 100, 250, 220); gfx.DrawRectangle(XBrushes.SeaShell, rect); tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With