PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

Get the height of a table
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2808
Page 1 of 1

Author:  bizzel74 [ Wed May 07, 2014 2:28 pm ]
Post subject:  Get the height of a table

Is there a way to get the height of a table?

The render object method does not take a section so I am having to use several tables.

docRend.RenderObject(gfx, XUnit.FromPoint(Margin), XUnit.FromPoint(Current_Top), "16cm", table)

I would like to know the height of the table so when I add the next table I can use an accurate Y pos (e.g. in the variable Current_Top).

Author:  Thomas Hoevel [ Wed May 07, 2014 2:35 pm ]
Post subject:  Re: Get the height of a table

Hi!

To get the height, see information given in this thread:
viewtopic.php?p=1960#p1960

The simple approach: render the whole document and MigraDoc will position the tables automatically.

Author:  bizzel74 [ Thu May 08, 2014 9:16 am ]
Post subject:  Page breaking when mixing PdfSharp and MigraDoc

I have a document which is:
      First page as PdfSharp
      Second page as MigraDoc
      Third page could be either

The problem I had with MigraDoc was that it was not wrapping to the next page. Even using a section page break did not seem to work.
I am outputting the MigraDoc parts with
Code:
docRend.RenderObject(gfx, XUnit.FromPoint(Margin), XUnit.FromPoint(Current_Top), "16cm", tablePage2)


Not sure if this is the best strategy as I always have to specify the Y position.

I would be happy to have the last page as PdfSharp but the paging is thrown out by the MigraDoc page, therefore Page 3 shows as Page 2 of 2 (not Page 3 of 3).

I might just have to manually hard code the paging in the footer :/

Author:  Thomas Hoevel [ Thu May 08, 2014 9:27 am ]
Post subject:  Re: Page breaking when mixing PdfSharp and MigraDoc

With MigraDoc, you can set the starting page number for every section. Just set it to two.

Use docRenderer.RenderPage instead of RenderObject and the pages will break automatically.
See also:
http://www.pdfsharp.net/wiki/MixMigraDo ... ample.ashx

The sample draws several MigraDoc pages on one PDFsharp. You should create a new PDFsharp page for each MigraDoc page and draw page 1:1 (do not scale them down).

Author:  bizzel74 [ Thu May 08, 2014 3:39 pm ]
Post subject:  Page breaking when mixing PdfSharp and MigraDoc

Ok, that seems to be working well. :D

I notice you need to add page and graphics objects to handle the extra pages, otherwise the data appears on the same page...

For example:
Code:
PdfPage page3 = document.AddPage();
XGraphics gfx2 = XGraphics.FromPdfPage(page3);

gfx2.MUH = PdfFontEncoding.Unicode;
gfx2.MFEH = PdfFontEmbedding.Default;

// Render page 2
 docRend.RenderPage(gfx2, 2)

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