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

DrawString problem
https://forum.pdfsharp.net/viewtopic.php?f=2&t=479
Page 1 of 1

Author:  Grovah [ Wed Sep 17, 2008 10:16 am ]
Post subject:  DrawString problem

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

Author:  Grovah [ Wed Sep 17, 2008 1:58 pm ]
Post subject: 

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

Author:  gastan [ Sun Oct 19, 2008 7:20 pm ]
Post subject: 

yup, that did it

Author:  gastan [ Mon Oct 20, 2008 7:53 pm ]
Post subject: 

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 ?

Author:  Thomas Hoevel [ Tue Oct 21, 2008 7:58 am ]
Post subject: 

Use MigraDoc for high-level formatting features.

Author:  gastan [ Wed Oct 22, 2008 8:30 pm ]
Post subject: 

yeah
but thaen I need to do AddText, AddTextFormat, AddText, AddTextFormat all the time.
some simple markup would be pretty cool

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