I am working on word document generation from ASPOSE.net API. My requirnment is that I divided data into 3 tables. and each table should print on one page. therefore if I have 4 tables then 4 page, 6 table then 6 pages. for this I am using the below code which work fine it print 1 table on 1 page :
foreach (Aspose.Words.Table table in doc.GetChildNodes(NodeType.Table, true))
{
if (table.FirstRow != null)
{
if (table.FirstRow.FirstCell.Range.Text.Contains("Media Rights:") ||
table.FirstRow.FirstCell.Range.Text.Contains("Options:") ||
table.FirstRow.FirstCell.Range.Text.Contains("Obligations:") ||
table.FirstRow.FirstCell.Range.Text.Contains("Royalty:") ||
table.FirstRow.FirstCell.Range.Text.Contains("Guarantees:"))
{
Paragraph par = new Paragraph(doc);
table.ParentNode.InsertBefore(par, table);
builder.MoveTo(par);//move documentBuilder cursor to the paragraph
builder.InsertBreak(BreakType.PageBreak);
}
}
}
only problem is above code is unable to find that not to add page break on those cases when any table contains the data to its complete page. In this case next page table should not require page margin above.
Page margin required only in case where table data at page is less. otherwise next table will imediatly print after first table on same page. In this case I required page break as above code doing.
In case of table cotains data for a page which full the page then the next table does not require page break above to that as new table will auto start to begning of new page.
table.ParentNode.InsertBefore(par, table);
FROM ABOVE CODE HOW CAN I CHECK THAT PAGEBREAK SHOULD ONLY INSERT WHEN TABLE DATA IS NOT FULLY FILLED IN PAGE?
if table data in any page is full and I don't required page break above to table.
Any help will be appreciated..
Thanks