I have a table with several columns.
Hi Brandon,
I created a solution and attached it. I also attached the screenshot of what I would like to accomplish.
Thank you for your help,
Brandon
Hi Brandon,
var _pdf = new Document();<o:p></o:p>
float marginInPixels = (float)(72 * 0.5);
Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();
margin.Top = marginInPixels;
margin.Left = marginInPixels;
margin.Right = marginInPixels;
margin.Bottom = marginInPixels;
_pdf.PageInfo.Margin = margin;
_pdf.PageInfo.Height = Aspose.Pdf.PageSize.PageLetter.Height;
_pdf.PageInfo.Width = Aspose.Pdf.PageSize.PageLetter.Width;
Page section = _pdf.Pages.Add();
Aspose.Pdf.Table hTable = new Aspose.Pdf.Table();
hTable.Alignment = Aspose.Pdf.HorizontalAlignment.Left;
int groupNumber = 1;
int groupCounter = 0;
for (Int32 i = 0; i <= 500 - 1; i++)
{
groupCounter += 1;
var aRow = hTable.Rows.Add();
var aCell = aRow.Cells.Add();
//Create a table to be nested with the reference of 2nd cell in the row
Aspose.Pdf.Table tab2 = new Aspose.Pdf.Table();
tab2.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.5f, Aspose.Pdf.Color.Black);
tab2.DefaultCellPadding = new Aspose.Pdf.MarginInfo
{
Bottom = 1,
Left = 1,
Right = 1,
Top = 1
};
tab2.Alignment = Aspose.Pdf.HorizontalAlignment.Left;
//Add the nested table into the paragraphs collection of the cell
aCell.Paragraphs.Add(tab2);
for (int cnt = 1; cnt <= 3; cnt++)
{
//Create 1st row in the nested table
Aspose.Pdf.Row row21 = tab2.Rows.Add();
var aCell1 = row21.Cells.Add();
aCell1.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("value 1"));
var aCell2 = row21.Cells.Add();
aCell2.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("Group " + groupCounter));
}
}
section.Paragraphs.Add(hTable);
_pdf.Save(myDir+"TestTable_group.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
Thanks for the response. I will check it out.
When building a pdf, I should use Document not PDF under the generators namespace? What is the recommended type and what is the difference?
Thank you,
Brandon
Hi Brandon,
So with nested tables, by default the child table will attempt to stay on the same page without a page break? If you wanted to stop the group and allow the child table to be split what setting would that be?
Hi Brandon,
The issues you have found earlier (filed as PDFNEWNET-36915) have been fixed in Aspose.Pdf for .NET 9.3.0.
Blog post for this release can be viewed over this link
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi Brandon,
string outFile =
myDir+“36915.pdf”;<o:p></o:p>
// Added document
var _pdf = new Document();
float marginInPixels = (float)(72 * 0.5);
Aspose.Pdf.MarginInfo margin1 = new Aspose.Pdf.MarginInfo();
margin1.Top = marginInPixels;
margin1.Left = marginInPixels;
margin1.Right = marginInPixels;
margin1.Bottom = marginInPixels;
_pdf.PageInfo.Margin = margin1;
_pdf.PageInfo.Height = Aspose.Pdf.PageSize.PageLetter.Height;
_pdf.PageInfo.Width = Aspose.Pdf.PageSize.PageLetter.Width;
Page section = _pdf.Pages.Add();
Aspose.Pdf.Table hTable = new Aspose.Pdf.Table();
hTable.Alignment = Aspose.Pdf.HorizontalAlignment.Left;
int groupNumber = 1;
int groupCounter = 0;
for (Int32 i = 0; i <= 50 - 1; i++)
{
groupCounter += 1;
var aRow = hTable.Rows.Add();
//set IsRowBroken property to true to break rows
aRow.IsRowBroken = true;
var aCell = aRow.Cells.Add();
//Create a table to be nested with the reference of 2nd cell in the row
Aspose.Pdf.Table tab2 = new Aspose.Pdf.Table();
tab2.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.5f, Aspose.Pdf.Color.Black);
tab2.DefaultCellPadding = new Aspose.Pdf.MarginInfo
{ Bottom = 1, Left = 1, Right = 1, Top = 1 };
tab2.Alignment = Aspose.Pdf.HorizontalAlignment.Left;
//Add the nested table into the paragraphs collection of the cell
aCell.Paragraphs.Add(tab2);
for (int cnt = 1; cnt <= 34; cnt++)
{ //Create 1st row in the nested table
Aspose.Pdf.Row row21 = tab2.Rows.Add();
var aCell1 = row21.Cells.Add();
aCell1.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("value 1"));
var aCell2 = row21.Cells.Add();
aCell2.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("Group " + groupCounter));
}
}
section.Paragraphs.Add(hTable);
_pdf.Save(outFile);
Please feel free to contact us for any further assistance.
Best Regards,