PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Mon Jul 14, 2025 3:26 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed May 07, 2014 2:28 pm 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
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).


Top
 Profile  
Reply with quote  
PostPosted: Wed May 07, 2014 2:35 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3131
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu May 08, 2014 9:16 am 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
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 :/


Top
 Profile  
Reply with quote  
PostPosted: Thu May 08, 2014 9:27 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3131
Location: Cologne, Germany
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).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu May 08, 2014 3:39 pm 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
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)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group