Free Support Forum - aspose.com

Product Listing with table heading on each page

I'm looking for something similar to a datagrid, ie convert the data listing to a pdfdocument.

ProductName Qty Price

a 1 10

b 2 20

.....

productName Qty Price

z 3 30

My problem is I need the table heading on the top of each page.

I am taking the invoice example http://www.aspose.com/Products/Aspose.Pdf/Demos/Northwind.aspx?index=Invoice

I just want the product listing part, but there are around 1000 products. So I need the product header on top of each page.

Please see the attached file. If I can repeat the table heading on page2 and so on... I'm done. I am retrieving data from the database.

Please provide me with a sample program.

Thanks in adavance.

Thanks for considering Aspose.

Please set the Header Section.IsNewPage to false.

Thanks for the reply. Unfortunately I'm new to ASPOSE.PDF and doing an evaluation to find out this can fit into our project requirement and if yes go for a purchase.

Well..

my page has a header and footer.

Then a tableheader and several data rows.

Page Header

Table header.

Table rows.

Footer.

As there is only one table, I'm getting the table header only once.

Other wise if I can add a table header as page header, that could be a solution.

Could you please help me.

Thanks in advance

Please refer to http://www.aspose.com/Wiki/default.aspx/Aspose.Pdf/ControlTableAndRowSplitting.html. Is the "Repeating First Row" you need?

Thank you very much for your help. It really solved the main problem.

Can I ask something more.

Basically I am retrieving the data for the main table using a dynamic search criteria. Now my output for the main part is coming perfect with table.IsFirstRowRepeated = True.

I can make the report more acceptable if I can print and repeat the "search criteria" on top of each page. Since I am not sure where the page is splitted, I can't add it programatically (sorry I'm not experienced in aspose.pdf). So If I can create a table in the header section, it should be available on top of each page, correct?

So the pdf report will be as follows

Page Header - text

Search Criteria (small table or text)

data table header.

Table rows.

Footer.

---

Page Header - text

Search Criteria (small table or text)

data table header.

Table rows.

Footer.

...

and so on....

Any suggestions please?

Thanks in advance.

You can try creating a section for each "search criteria" and put the "search criteria" in the header of each page in the section. If you don't want each section starts a new page, please set the Section.IsNewPage to false.

Thanks for your reply.

Could you please provide a sample code in VB.net please. Sorry, I'm very new to Aspose.pdf.

Thanks in advance.

Here is a small example:

Dim pdf As Pdf = New Pdf

Dim sectionIndex As Integer
For sectionIndex = 0 To 10
Dim sec As Section = pdf.Sections.Add

Dim header As HeaderFooter = New HeaderFooter
sec.OddHeader = header
sec.EvenHeader = header

Dim text1 As Text = New Text("header")
header.Paragraphs.Add(text1)
text1 = New Text("Search Criteria " + sectionIndex.ToString())
header.Paragraphs.Add(text1)

Dim footer As HeaderFooter = New HeaderFooter
sec.OddFooter = footer
sec.EvenFooter = footer

text1 = New Text("footer")
footer.Paragraphs.Add(text1)

Dim rowIndex As Integer
Dim table As Table = New Table
sec.Paragraphs.Add(table)
table.ColumnWidths = "100"
table.IsFirstRowRepeated = True
table.DefaultCellBorder = New BorderInfo(BorderSide.All)

Dim row As Row = table.Rows.Add
row.Cells.Add("table header")
For rowIndex = 0 To 100
row = table.Rows.Add
row.Cells.Add("row " + rowIndex.ToString())
Next

Next

pdf.Save("d:/test/test.pdf")