Aspose.Pdf.Generator and Aspose.Pdf.Generator.Table


#1

Hi there
I am using Aspose.PDF 11.0 version and have the following function to create a table.
And wanted to update with Aspose.PDF 17.6 version.
And 17.6 version don’t support Aspose.Pdf.Generator and Aspose.Pdf.Generator.Table.
Can you please let me know how it can be achieved with 17.6

Thanks in Advance
Jegadeesh S

sample code:
public string GenerateKnowledgeManagementPdfReport()
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(“Aspose.Total.lic”);
var report = CreateDummyKnowledgeManagementReport();
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
CreateDescriptionTable(sec1);
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
sec1.Paragraphs.Add(tab1);
tab1.ColumnWidths = “170 170”;
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);
Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo() { Top = 5f, Bottom = 5f, Left = 5f, Right = 5f };
tab1.DefaultCellPadding = margin;
var headerList = new List();
headerList = report.TabularData[0].Any() ? report.TabularData[0] : new List { “_” };
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
for (int i = 0; i < headerList.Count; i++)
{
row1.Cells.Add(headerList[i]);
}

        var withoutHeaderList = report.TabularData.Skip(1);
        foreach (var item in withoutHeaderList)
        {
            Aspose.Pdf.Generator.Row row2 = tab1.Rows.Add();
            for (int j = 0; j < item.Count; j++)
            {
                row2.Cells.Add(item[j]);
            }
        }

        pdf1.Save("d:/pdftest/TableResult.pdf");
        return "D://pdftest/TableResult.pdf";
    }

#2

@mhorg

Thank you for contacting support.

Please note these documents are obsolete now and new DOM (Document Object Model) of Aspose.PDF for .NET API has different enhanced classes and properties as explained below:

Instead of using Generator.Pdf, please use Aspose.Pdf.Document class, and sections are now Pages.

Aspose.Pdf.Page page1 = document.Pages.Add()

Furthermore, Table, MarginInfo, Row and BorderInfo classes exist under Aspose.Pdf namespace.

tab1.DefaultCellPadding = new MarginInfo(5, 5, 5, 5 );
tab1.DefaultCellBorder = new BorderInfo(BorderSide.All, 0.1F, Aspose.Pdf.Color.Black);
Aspose.Pdf.Row row1 = tab1.Rows.Add();

Moreover, we recommend using latest available versions because they include more features and bug fixes so please try Aspose.PDF for .NET 19.8.