Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Horizontal split of table in to new page.

$
0
0
Hi Team,
I have a table with some data which does'nt fit in the current page. It cuts the few columns.
It is possible to split the table in horizontal and move it to the new page.


// Instantiate an object PDF class
            Aspose.Pdf.Generator.Pdf pdf = new Pdf();
            // add the section to PDF document sections collection
            Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
            //Instantiate a table object
            Aspose.Pdf.Generator.Table mytable = new Aspose.Pdf.Generator.Table();
            mytable.Margin.Top = 300;
            //Add the table in paragraphs collection of the desired section
            sec1.Paragraphs.Add(mytable);
            //Set with column widths of the table
            mytable.ColumnWidths = "100 100 100 100 100 100 100";
                    
            // if you increase the counter to 17, table will break 
            //because it cannot be accommodated any more over this page
            for (int RowCounter = 0; RowCounter <= 50; RowCounter++)
            {
                //Create rows in the table and then cells in the rows
                Aspose.Pdf.Generator.Row row1 = mytable.Rows.Add();
                row1.Cells.Add("col " + RowCounter.ToString() + ", 1");
                row1.Cells.Add("col " + RowCounter.ToString() + ", 2");
                row1.Cells.Add("col " + RowCounter.ToString() + ", 3");
                row1.Cells.Add("col " + RowCounter.ToString() + ", 4");
                row1.Cells.Add("col " + RowCounter.ToString() + ", 5");
                row1.Cells.Add("col " + RowCounter.ToString() + ", 6");
                row1.Cells.Add("col " + RowCounter.ToString() + ", 7");
            }
            // get the Page Height information
            float PageHeight = pdf.PageSetup.PageHeight;
            // get the total height information of Page Top & Bottom margin,
            // table Top margin and table height.
            //float TotalObjectsHeight = section.PageInfo.Margin.Top + section.PageInfo.Margin.Bottom + table1.Margin.Top + table1.GetHeight(pdf);

           // pdf.Save(@"D:/pdftest/TableIsBrokenTest.pdf");
           
           mytable.IsBroken = true;
           
            // add table to paragraphs collection of section
          //  sec1.Paragraphs.Add(mytable);
            // save the resultant PDF document
            pdf.Save(@"D:\test\DynamicTableWidth.pdf");

Viewing all articles
Browse latest Browse all 3131

Trending Articles