PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon May 06, 2024 4:53 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: DrawString problem
PostPosted: Wed Sep 17, 2008 10:16 am 
Offline

Joined: Wed Sep 17, 2008 10:04 am
Posts: 4
Hello!

I am quite new to PDFSharp and I have a problem. I am trying to draw a multiline string with the XGraphics object in the same way as I do with ordinary Graphics object.

Printing this to printer using the Graphics works fine, the text in m_strText wraps within the rectangle:
RectangleF rectText = new RectangleF(500, 100, 200, 500);
ev.Graphics.DrawString(m_strText , m_Font, m_FontBrush, rectText);

While doing this with the XGraphics object, PDFSharp generates an error, stating "height must be 0":
XRect rectText = new XRect(500, 100, 200, 500);
gfx.DrawString(m_strText, m_Font, m_FontBrush, rectText);

If it is not possible to wrap text within a rectangle, is there any good desig pattern out there to solve that issue in PDFSharp?

Regards

/Magnus


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 17, 2008 1:58 pm 
Offline

Joined: Wed Sep 17, 2008 10:04 am
Posts: 4
Answering my own post, maybe it can help someone else ;).

A XTextFormatter object was the solution, found it in the "TextLayout" example C# project.

/G


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Oct 19, 2008 7:20 pm 
Offline
Supporter

Joined: Sat Oct 18, 2008 4:15 pm
Posts: 50
yup, that did it


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 20, 2008 7:53 pm 
Offline
Supporter

Joined: Sat Oct 18, 2008 4:15 pm
Posts: 50
anyway, I have now problem, that when I want to highlight some words in text I am putting together, I have to split it into pieces and add all bold text extra. Any idea on how that would be possible with some kind of formatting ?
like <b></b> in html ?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 21, 2008 7:58 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
Use MigraDoc for high-level formatting features.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Oct 22, 2008 8:30 pm 
Offline
Supporter

Joined: Sat Oct 18, 2008 4:15 pm
Posts: 50
yeah
but thaen I need to do AddText, AddTextFormat, AddText, AddTextFormat all the time.
some simple markup would be pretty cool


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 80 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