Pdf question



We are evaluating Aspose.Pdf to be used for report generation.
We have reports which have the following sequence:

Account Page Header
Participant Account Header
Participant Accounts [1-N] records
Participant Header
Participant Accounts [1-N] records
Participant Header
Participant Accounts [1-N] records

Transaction Page Header
Transaction Summary Header
Tran Summary [1-N] records
Transaction Summary Header
Tran Summary [1-N] records
Transaction Summary Header
Tran Summary [1-N] records

and many many other repeats of multiple sections

I am trying to figure out if I can use XML and API combination to create the PDF file,
but cannot understand how to make 1-N repeats of sections using XML.

I can picture doing everything in API but ideally XML looks more appealing to me.
Is it something that can be done using XML? Do u have any examples?



Dear Mark,

Thanks for your consideration.

I think what you want is to repeat paragraphs in the XML-API combination working mode. To define section or paragraph repeating in XML is not supported. But you can easyly make your table repeated by defining it in XML and cloning it in API. Here is an example:

(Please download the latest hotfix before runing this example)

<?xml version="1.0" encoding="utf-8" ?>







Pdf pdf1 = new Pdf();

Section sec1 = pdf1.Sections[0];
Table table1 = sec1.Paragraphs[“table1”] as Table;

Table curTable;
string[] items = new string[]{“item1”,“item2”,“item3”};
for(int i = 0; i < 5 ; i++)
curTable = table1.Clone() as Table;
curTable.Margin.Top = 10;
curTable.Rows.Add(table1.Rows[0].CompleteClone() as Row);


Dim pdf1 As Pdf = New Pdf()
pdf1.BindXML(“E:\Projects\CSharp\Doc\web\Guide\Example-XML\RepeatExample.xml”, Nothing)

Dim sec1 As Section = pdf1.Sections(0)
Dim table1 As Table = sec1.Paragraphs(“table1”)

Dim curTable As Table
Dim items() As String = New String() {“item1”, “item2”, “item3”}

Dim i As Integer
For i = 0 To 5 - 1 Step 1
curTable = table1.Clone()
curTable.Margin.Top = 10
curTable.ImportArray(items, 1, CType(0, Byte), False)



Hi Tommy,


What is the purpose of Segments?

I can picture defining more than 1 segmenst with different variations for different reports with in the same document. Sometimes I want to render to PDF from 1 segments and sometimes from the other.

Will XML always render all Segments? Is there a way to disable XML defined Segments from rendering for 1 report and enable for the other?

Please look at the end of PDF file I sent to see what I mean. It has many different subreports in it,




One other thing.

So say I define XML and want to use it programaticcaly like u suggested to clone tables and render them.

What about the part of the doc XML will render initially, before I even code anything?

Another word if I have code iterating some data and cloning some table(s) i keep everything under control except the very first page produced by XML. Do I understand it correctly?

The sequence of calls:

new PDF

will produce some PDF document, but how can I control which table to clone initially?



Dear Mark,

Thanks for your consideration.

I guess what you mean is Section but not Segment.

To disable XML defined Sections is not supported. But I can easyly add this feature for you if you want.


Dear mark,

Thanks for your consideration.

1) You can refer to the document object model of Aspose.Pdf. Sections are rendered by their order in the document’s sections collection. And paragraphs are rendered by their order in the section’s paragraphs collection. So if you want to repeat a table, you should clone that table and insert the cloned table into the section’s paragraphs collection at the position you want. What you need to do is to make sure the sections and paragraphs is in the right order according to the report you want to generate.

2) You want to repeat tables because some of your tables share the same features such as border format, column widths,etc. So if you want to add a new table and the table is like one of the table you have defined in your XML, then you can clone that table and add it to the paragraphs collection at any position you want.

Have I make it clear?



I think it will be a very powerfull feature (at least to us).

We can create set of Sections on a page and than control which one to use from API based on some values.



Dear Mark,

Thanks for your consideration.

Then I want to add a new property named “IsDisabled” to Section class. The default value is false. If you do not want to render a section, you can set this property to true in that section. For example, if you have defined 3 sections in the document with ID “sec1”,“sec2” and “sec3”, but you don’t want to render sec2, then you can use the following line in the API:

pdf.Sections[“sec2”].IsDisabled = true;

Is this what you want?


that would be very nice