PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Best way to structure a document
http://forum.pdfsharp.com/viewtopic.php?f=2&t=1284
Page 1 of 1

Author:  Craigbnz [ Thu Jul 29, 2010 8:14 pm ]
Post subject:  Best way to structure a document

Hi Guys,

I'm using MigraDoc to create a PDF document and have been playing around with a few different structures. I want to know which is the best way to layout a page. My documents are made up of about 8 difference blocks. Each block has a different number of columns, rows and border requirements.

Currently I have a single document section and an outer table. The outer table contains 3 columns, 1 for the left spacing, 1 for the right spacing and 1 for the contents.
All blocks are added into the centre cell of the outer table. So each block is effectively 1 row in the main outer table. The pros of this method is that I can easily adjust the left and right spacing and I can have a left and right border down the page without having to code the borders into each content block.

An alternative would be to add each block as a separate table to main section. With this approach I would have to add the right and left borders of the page to each block.

Are there any tricks or tips you can give me which will help me decide which is best.

BTW - love the product, great that we don't need any additional infrastructure like SSRS and it automatically calculates what can fit on a page.

Author:  Craigbnz [ Thu Jul 29, 2010 9:51 pm ]
Post subject:  Re: Best way to structure a document

Hi Guys,

After further investigation it appears that the first approach is not a very good one. This does not allow for the inner table to automatically continue onto a new page.
I.e. if I have one row in the outer table and 20 rows in the inner table (located in OuterTable[0,1]) then the inner table will not split onto a new page if required.

Instead it looks like I need to Add each block to the main section. The problem with this approach is that there is no way to Keep one table in the section with another table in the section. E.g. in the example below I want to keep table 1 with table 2

Section
- Table 1
Row 1 cell 1, row 1 cell 2, row 1 cell 3
Row 2 cell 1, row 1 cell 2, row 1 cell 3
Row 3 cell 1, row 1 cell 2, row 1 cell 3
- Table 2
Row 1 cell 1
Row 2 cell 1

The only way I can think of to keep Table 2 with Table 1 is to have Table 2 internal to Table 1. i.e.
Section 1
- Table 1
Row 1 cell 1, row 1 cell 2, row 1 cell 3
Row 2 cell 1, row 1 cell 2, row 1 cell 3
Row 3 cell 1, row 1 cell 2, row 1 cell 3
Row 4 cell1.MergeRight 2
- Table 2
Row 1 cell 1
Row 2 cell 1

I just hope Table 1 will now automatically split over to a new page if it contains too many rows.

Cheers

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/