PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Drawstring auto extending rectangle https://forum.pdfsharp.net/viewtopic.php?f=2&t=1295 |
Page 1 of 1 |
Author: | breath2k [ Fri Aug 13, 2010 10:13 am ] |
Post subject: | Drawstring auto extending rectangle |
I have been using pdfsharp and have been using xrect, DrawRectangle and DrawString to layout my pages, however, I have come across a page I need to create whereby the text could be any length at all as its an ntext field from a database. Can the drawstring method automatically increase the height of the rectangle its contained in if the text is longer than the rectangle? |
Author: | breath2k [ Fri Aug 13, 2010 3:26 pm ] |
Post subject: | Re: Drawstring auto extending rectangle |
as no replies yet went about testing with Graphics.MeasureString instead and used the width from the measurement divided by the width of the rectangle/column I was inputting to get the number of lines it would overlap by: Code: fontheight = gfx.MeasureString(student.Notes, font); textsize = fontheight.Height; noLines = fontheight.Width / colWidth; if (noLines > Convert.ToInt32(noLines)) noLines = Convert.ToInt32(noLines) + 1; findTopHeight = textsize * noLines; rect = new XRect(PageMargin, accHeightLoc, colWidth, findTopHeight); It works ok but I would love to know of any better solutions. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |