We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Multiple Tables

Hello,


I am using Aspose PDF for .NET to attempt to render some reports.

I am trying to render two tables on a single PDF Document using the table object. Both tables are quite long and therefore go into multiple pages.

I am currently setting up the first table populating it with data and then adding it to the page. Then I am taking a new page, setting up a new table then adding it to the next page

// Add the first table
Page page = doc.Pages.Add();
Table table;
SetupTable(out table);
Row newRow;
foreach(DataRow dr in dt.Rows)
{
newRow = table.Rows.Add();
}
page.Paragraphs.Add(table);

page = doc.Pages.Add();
SetupTable(out table);
foreach(DataRow dr in dt2.Rows)
{
newRow = table.Rows.Add();
}
page.Paragraphs.Add(table);


The result of all this is the first part of table 1 appears in page 1, then on page 2 I get the first part of table 2. Then in the next pages I get the remaining parts of table 1 and table 2.

Any help would be most welcome.

Thanks

Hi Neil,


Thanks for your inquiry. Please do not add new page again. Your second table will automatically starts after first table. Please remove highlighted code, it will help you to accomplish the task.


// Add the first table
Page page = doc.Pages.Add();
Table table;
SetupTable(out table);
Row newRow;
foreach(DataRow dr in dt.Rows)
{
newRow = table.Rows.Add();
}
page.Paragraphs.Add(table);

page = doc.Pages.Add();
SetupTable(out table);
foreach(DataRow dr in dt2.Rows)
{
newRow = table.Rows.Add();
}
page.Paragraphs.Add(table);

Please feel free to contact us for any further assistance,

Best Regards,

Thanks Tilal,


That works fine but the tables just group together I want to add a bit of white space there and/or a page break is there an easy way to do this.

I tried just adding in a Floating Box of Height 20 but that didn’t seem to make any difference.

Hi Neil,


In order to add white space, do you think adding a blank TextFragment can accomplish your requirement.

I don’t see how I would be able to set the height of the blank TextFragment to give me a reasonable space.


I tried placing the Text Fragment in a FloatingBox but the Table just overwrote the area (i.e the box was there but the table was over the top)

Hi Neil,


Thanks for your feedback. As another workaround for page break, you can achieve your requirements by using IsInNewPage property of first row, it will always start table from new page.

row1.IsInNewPage = true;<o:p></o:p>


Please feel free to contact us for any further assistance.


Best Regards,


Okay that is good to know but it there anyway to just take a gap between the tables.


We currently have reports that can do this generated by another means, I am looking at bringing a few different solutions we have to generating PDF Reports into one solution.

Hi Neil,


Thanks for your feedback. To add gap between tables by adding an empty table as following.


Aspose.Pdf.Table tab = new
Aspose.Pdf.Table();<o:p></o:p>

Aspose.Pdf.Row row = tab.Rows.Add();

row.FixedRowHeight = 45.0f;

row.Cells.Add();

page.Paragraphs.Add(tab);


Best Regards,

Thanks for the support. I seem to be making progress and was quite close to getting out what I wanted but every now and then I run into the following error.

Non-negative number required.
Parameter name: count

I could send full details of the error but it occurs when the document is saved. I have attached an example project of when it occurs. In this example project if you do the table gaps through the tabbed method then it work but as soon as you use the paging method it breaks.

I have actually had this error a few times when trying to do this grouping. It also occurs on my actual project when I do double grouping and change the repeated rows to 3 but this was harder to make a example Project for so I am hoping this is enough for you guys to debug from.

I have included my code but have removed my licence file as I assume these shouldn’t be posted here.

Hi Neil,


Thanks for sharing the sample project.

I have tested the scenario and I am able to
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWNET-36636 in our issue tracking system. We will further
look into the details of this problem and will keep you updated on the status
of correction. Please be patient and spare us little time. We are sorry for
this inconvenience.

Any update on this issues.


I only ask as I am on the months free trial and therefore I’m keen to see this working before the trial runs out. I am testing out a piece of functionality that we would like to add to our application but won’t be need to run a Proof of Concept on the item before we commit to buying any new software.

Thanks in Advance
Neil W. Bruce

Hi Neil,


Thanks for your inquiry. We have a good news for you, your above reported issue has been resolved and its fix will be included in upcoming release of Aspose.Pdf for .NET i.e. 9.1.0. Hopefully it will be published within this week. However, we will notify you via this forum thread as soon as it is published and gets available for download.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-36636) have been fixed in Aspose.Pdf for .NET 9.1.0.

For further details, you may check this blog post.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.