PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:24 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 Mar 07, 2014 9:00 am 
Offline

Joined: Fri Mar 07, 2014 8:52 am
Posts: 2
Can I change font size of Style without recreating whole document.
I want to put this in cycle
to fit table on a page
by decreasing table font size.

But it seems it doesn't work this way.
Code:
Document document;
// Create a new PDF document
document = CreateDocument();

// Create a renderer and prepare (=layout) the document
MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(document);
docRenderer.PrepareDocument();
pageCount = docRenderer.FormattedDocument.PageCount;

while (pageCount > 1)
{
   ScheduleFontsize -= 1;
   document.Styles["ScheduleBody"].Font.Size = ScheduleFontsize;

   // Create a renderer and prepare (=layout) the document
   docRenderer = new DocumentRenderer(document);
   docRenderer.PrepareDocument();
   pageCount = docRenderer.FormattedDocument.PageCount;
}


Somewhere in CreateDocument();
...
row2.Cells[1].Style = "ScheduleBody";
...


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 10, 2014 9:40 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
That should work.
Don't forget to create the style in CreateDocument() or you will get bright green text.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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: Google [Bot] and 148 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