PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

PDFSharp Paragraph text?
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1928
Page 1 of 1

Author:  tulips [ Thu Mar 01, 2012 2:06 pm ]
Post subject:  PDFSharp Paragraph text?

Hello!

I have a question about free text display in pdfsharp. I want the text to be displayed in one paragraph. The text can be long.
string remarks =
"This exam is over and I think I did okay. Not so bad. Some modules were tough and some were easy. Some calculations were hard and I just hope I get good marks. The graphical analysis looks good. I can see how I did. I could have prepared more but I guess you can always say that. Long enough remarkds to go on few lines";
XRect rect = new XRect(L, T + 100, 440, 340);
XTextFormatter xtf = new XTextFormatter(gfx3);
xtf.LayoutRectangle = rect;
xtf.Alignment = XParagraphAlignment.Justify;
gfx3.DrawString(remarks, font, XBrushes.Black, rect, XStringFormats.TopLeft);

But still the text is displayed in 1 line and it gets cut once the page width is reached. How can I display this in a paragraph?

Thanks.

Have a good day!

-tulips

Author:  hoylemd [ Thu Mar 01, 2012 2:34 pm ]
Post subject:  Re: PDFSharp Paragraph text?

Hi,

You should use the XTextFormatter's DrawString() method to draw on multiple lines.

so change

Code:
gfx3.DrawString(remarks, font, XBrushes.Black, rect, XStringFormats.TopLeft);

to

Code:
xtf.DrawString(remarks, font, XBrushes.Black, rect, XStringFormats.TopLeft);

Author:  tulips [ Mon Mar 05, 2012 10:25 am ]
Post subject:  Re: PDFSharp Paragraph text?

Thanks! It worked!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/