Hello,
As i said in my earlier post the problem is explained again with some reference code & sample document.
I am currently using
Aspose word version 6.2.0.0
Aspose PDF 5.9.0.0
Please find the attached copy of word document.
In attached document there are 2 sections #1 & #2. For both section there is some text available at initial place & then table object is drawn.The size of table object is coming from outside as input parameter from user but for better understanding of problem & sample coding it is put as fixed or static.
Senario#1
After printing initial text, i have to print a table, the size of table is 4*4 which small as compare to page size or which do not goes beyond the current page so it is printed on same page.
Scenario #2
Here now the size of table is large.
So the table is started printing on same page & get divided into page 2 & 3
So my requirement is that i want intial text to be printed on 2 page but table should start printing on 3 rd page instead of 2
So the entire table will grab 3 page.
But i want this course of action to be done dynamically by sensing that wheather the end of page is ocurred or not ( i do not want to use any explicit pagebreak before or after table to achieve this.)
Is it possible for us to sense the end of page at the time of printing?
or
is there any alternative way to achieve this?
the sample code for this is as follows.
//path for license directory.
string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
//Initialize Aspose license.
Aspose.Words.License lic = new Aspose.Words.License();
lic.SetLicense(path + @"\Aspose.Total.lic");
Aspose.Pdf.License lic1 = new Aspose.Pdf.License();
lic1.SetLicense(path + @"\Aspose.Total.lic");
//Create document & document builder object.
Document doc = new Document();
DocumentBuilder documentBuilder = new DocumentBuilder(doc);
//Start of Scanario #1
documentBuilder.Font.Bold = true;
documentBuilder.Writeln(“Scenario #1: Table Fit into Page”);
documentBuilder.Font.Bold = false;
documentBuilder.InsertBreak(BreakType.LineBreak);
//Some text available on page.
documentBuilder.Writeln(“At the Nokia World 09 underway in Stuttgart, Nokia seems to be telling the world that it STILL is the world’s number one mobile phone manufacturer even though its dominance might have been challenged by relative new comers.”);
documentBuilder.Write(“Whenever we say newcomer, the first thing that comes to the mind is undoubtedly, Apple. When Apple introduced the iPhone back in 2007, it was a revolutionary device right from the design to its UI”);
documentBuilder.Write("Two years after its introduction, many devices have tried to be an iPhone killer but none of them really managed to cause any dent into the sales of the iPhone, let alone kill it. However, by 2009 ");
documentBuilder.Write(“we have a relative flood of new devices that are actually capable of doing things way better than the iPhone and they look good whilst doing it as well, a key iPhone feature! So, we now have the Android with the Sense UI on HTC”);
documentBuilder.Write(" Palm with its extremely slick WebOS and Nokia with Series 60 Version 5! What? Series 60? ");
//Clear the paragraph formatting for new paragraph.
documentBuilder.InsertBreak(BreakType.ParagraphBreak);
documentBuilder.ParagraphFormat.ClearFormatting();
documentBuilder.InsertBreak(BreakType.LineBreak);
//Print text in BOLD format.
documentBuilder.Font.Bold = true;
documentBuilder.Writeln(“Table fit into remaining Page”);
documentBuilder.StartTable();
//Creating table with 4 * 4 matrix.
documentBuilder.Writeln(“Table with Only 4 rows & 4 cols”);
documentBuilder.Font.Bold = false;
//Initialise the table parameter.
//Consider that row & col data is not fix or static
//It is coming from outside.( so it is dynamic )
//Based on these two parameters the size of table will get configured.
//Lets assume the input is 4*4 table from outside.
int row =4;
int col =4;
//Printing exact table.
for (int i = 0; i < row; ++i)
{
for (int j = 0; j < col; ++j)
{
documentBuilder.InsertCell();
}
documentBuilder.EndRow();
}
documentBuilder.EndTable();
//Insert page break to go to next page.
documentBuilder.InsertBreak(BreakType.PageBreak);
documentBuilder.ParagraphFormat.ClearFormatting();
//Start of Scenario #2
documentBuilder.Font.Bold = true;
documentBuilder.Writeln(“Scenario #2: Table do not fit into Page & divide into pages.”);
documentBuilder.Font.Bold = false;
documentBuilder.InsertBreak(BreakType.LineBreak);
//Some text available at start.
documentBuilder.Writeln(“At the Nokia World 09 underway in Stuttgart, Nokia seems to be telling the world that it STILL is the world’s number one mobile phone manufacturer even though its dominance might have been challenged by relative new comers.”);
documentBuilder.Write(“Whenever we say newcomer, the first thing that comes to the mind is undoubtedly, Apple. When Apple introduced the iPhone back in 2007, it was a revolutionary device right from the design to its UI”);
documentBuilder.Write("Two years after its introduction, many devices have tried to be an iPhone killer but none of them really managed to cause any dent into the sales of the iPhone, let alone kill it. However, by 2009 ");
documentBuilder.Write(“we have a relative flood of new devices that are actually capable of doing things way better than the iPhone and they look good whilst doing it as well, a key iPhone feature! So, we now have the Android with the Sense UI on HTC”);
documentBuilder.Write(" Palm with its extremely slick WebOS and Nokia with Series 60 Version 5! What? Series 60? ");
//Clear the paragraph formatting for new paragraph.
documentBuilder.InsertBreak(BreakType.ParagraphBreak);
documentBuilder.ParagraphFormat.ClearFormatting();
documentBuilder.InsertBreak(BreakType.LineBreak);
//Print text in BOLD format.
documentBuilder.Font.Bold = true;
documentBuilder.Writeln(“Table do not fit into remaining page”);
documentBuilder.StartTable();
//creating table with 50 * 4 matrix.
documentBuilder.Writeln(“Table with Only 50 rows & 4 cols”);
documentBuilder.Font.Bold = false;
//Table formation.
int newRow = 50;
int newCol = 4;
for (int i = 0; i < newRow; ++i)
{
for (int j = 0; j < newCol; ++j)
{
documentBuilder.InsertCell();
}
documentBuilder.EndRow();
}
documentBuilder.EndTable();
//Save document & open into aspose word.
doc.Save(“Sample.doc”);
Waiting for your reply ASAP.
Thanks & Regards,
Dwarika