PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
DrawText https://forum.pdfsharp.net/viewtopic.php?f=2&t=1690 |
Page 1 of 1 |
Author: | neticous [ Mon Jun 13, 2011 7:28 pm ] |
Post subject: | DrawText |
Why does drawtext draw outside of the supplied rectangle? Shouldn't it clip the the rectangle? Thanks neticous |
Author: | Thomas Hoevel [ Tue Jun 14, 2011 7:29 am ] |
Post subject: | Re: DrawText |
There is no simple way to implement clipping in PDF. |
Author: | neticous [ Wed Jun 15, 2011 9:08 pm ] |
Post subject: | Re: DrawText |
I simply did this. XFont printfont ... string Value = some long string.... Rectangle r = some text rectangle XStringFormat f = XStringFormat ... XSize lengthOfText = gfx.MeasureString(Value, printfont); string textValue = Value; if (lengthOfText.Width > (double)r.Width) { while (lengthOfText.Width > (double)r.Width) { textValue = textValue.Remove(textValue.Length - 1, 1); lengthOfText = gfx.MeasureString(textValue, printfont); } } gfx.DrawString(textValue, printfont, XBrushes.Black, r, f); Works like a charm. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |