PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Apr 23, 2024 6:00 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Jun 07, 2016 9:37 am 
Offline

Joined: Tue Jan 12, 2016 12:17 pm
Posts: 9
Hello,

I would like to know how to trigger a page break during a table generation.

Here a sample of my code
Code:
Document migraDoc = new Document();
Section migraSection = migraDoc.AddSection();
Table migraTable = migraDoc.LastSection.AddTable();
migraTable.AddColumn();
// Setup which is doing well...

foreach (var row in rowList)
{
       if(row.type == "pageBreak")
       {
              // TRIGGER A PAGE BREAK NEEDED
       }
       else
       {
              Row migraRow = migraTable.AddRow();
              // stuff which is doing well...
       }
}


Automatic page breaks work very well, but I may want to perform a page break even if I leave enough space for rows.

Thank you.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 07, 2016 2:34 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 916
Location: CCAA
Hi!

My workaround would be: add a pagebreak after the table and start a new table when more data follows.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 07, 2016 3:45 pm 
Offline

Joined: Tue Jan 12, 2016 12:17 pm
Posts: 9
Tricky but it's working well

Thanks.

Code:
Document migraDoc = new Document();
Section migraSection = migraDoc.AddSection();
Table migraTable = migraDoc.LastSection.AddTable();
SetUpTable(migraTable); // function that set the table up.
// Setup which is doing well...

foreach (var row in rowList)
{
       if(row.type == "pageBreak")
       {
              migraSection.AddPageBreak();
              migraTable = migraDoc.LastSection.AddTable();
              SetUpTable(migraTable); // don't forget to redo the setup
       }
       else
       {
              Row migraRow = migraTable.AddRow();
              // stuff which is doing well...
       }
}


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 187 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