PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Sep 27, 2024 2:45 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Aug 13, 2010 10:13 am 
Offline

Joined: Fri Aug 13, 2010 10:04 am
Posts: 6
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?


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 13, 2010 3:26 pm 
Offline

Joined: Fri Aug 13, 2010 10:04 am
Posts: 6
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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