PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Jul 18, 2024 1:29 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: PDFSharp Paragraph text?
PostPosted: Thu Mar 01, 2012 2:06 pm 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
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


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 01, 2012 2:34 pm 
Offline

Joined: Thu Feb 09, 2012 4:59 pm
Posts: 14
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);


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 05, 2012 10:25 am 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
Thanks! It worked!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group