Dynamic PDF generation with nested tables structures

387 views
Skip to first unread message

Support

unread,
Feb 14, 2012, 8:15:31 PM2/14/12
to pdfne...@googlegroups.com
Q:
 
Our application has a new requirement to generate PDF documents dynamically on the fly from some uploaded files (proprietary file type).

 

Currently we’re extracting data from the file and then dynamically create a HTML document on the fly and then convert to PDF using some other third-party PDF component.

 

We’re looking to eliminate the step which convert from HTML to PDF, whereby we would like to dynamically generate the PDF from the data extracted from the file.

 

To kick start, I would like to ask whether your SDK can support the generation of nested tables structures as it is one of the mandatory requirements.

And I would like to have some sample code on this if possible.

 

I would give me more requirements and even sample results PDF for your analysis to help you understand what we need and how your PDFNet SDK and possibly other add-ons

 
--------------
A:
 

The easiest way to create nested table structures is through PDFNet’s Convert add-on with WPF/.NET

In this scenario, you can dynamically create your nested tables with Microsoft’s WPF Flow Document API.

http://msdn.microsoft.com/en-us/library/aa970909.aspx

 

Then use pdftron.Xaml.Convert.ToPdf() to directly convert your FlowDocument object into PDF.

 

To see a sample project that shows how to do this, please download our PDFNet SDK trial (make sure you choose the .NET version) and see the Xaml2PDF sample.

 

http://www.pdftron.com/pdfnet/samplecode.html#Xaml2PDF

 

 

For your specific requirements for nested tables, it is supported in FlowDocument and should be converted to PDF without problem.

 

You can test out table nesting by using the follow snippet with our sample project.

 

static public void CreateXamlTableAndConvert()

{

            Table table2 = new Table();

            table2.CellSpacing = 10;

            table2.Background = Brushes.Pink;

            table2.Columns.Add(new TableColumn());

            table2.Columns[0].Background = Brushes.HotPink;

            table2.RowGroups.Add(new TableRowGroup());

            table2.RowGroups[0].Rows.Add(new TableRow());

            TableRow r = table2.RowGroups[0].Rows[0];

            r.Cells.Add(new TableCell(new Paragraph(new Run("NESTED TABLE"))));

            r.Cells.Add(new TableCell(new Paragraph(new Run("NESTED TABLE"))));

            r.Cells.Add(new TableCell(new Paragraph(new Run("NESTED TABLE"))));

currentRow.Cells.Add(new TableCell(table2));

}

 

 

Btw. PDFNet also supports conversion from in memory HTML (see http://www.pdftron.com/pdfnet/samplecode.html#Html2Pdf).

 

 

Reply all
Reply to author
Forward
0 new messages