PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Apr 28, 2024 2:20 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
 Post subject: Table AutoFit
PostPosted: Fri Mar 12, 2010 1:33 pm 
Offline

Joined: Thu Mar 11, 2010 2:16 pm
Posts: 9
Hi,

is there anyway to autofit the table to the width of the page (something that does the same as the autofit to window Word2007 option)?

Regards,
Joel


Top
 Profile  
Reply with quote  
 Post subject: Re: Table AutoFit
PostPosted: Fri Mar 12, 2010 3:07 pm 
Offline
Supporter

Joined: Fri May 15, 2009 3:28 pm
Posts: 96
you can get the width of a MigraDoc Document and the left/right margins too - maybe even the .ContentArea? just work out the column widths from that. I personally pass in an array of doubles (which are percentages of the page width i.e. 10, 10, 20, 20, 40 to the function i use to create tables, this function then gets the .ContentArea of the document and set the .Width property on each column to be:

Code:
for(int i = 0; i < tableCols.length; i++)
    col[i].width = (pageContentBox.width / 100) * widthsArray[i];


so long as you make sure the array of doubles always adds upto 100, then it should always "autofit", even if you change your page from Portrait to landscape or visa-versa.

Mike


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 227 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