PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jul 01, 2024 12:23 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Feb 21, 2013 3:04 am 
Offline

Joined: Thu Feb 21, 2013 2:57 am
Posts: 3
Hi,
I have a Migradoc pdf document that is generated that can be a varying number of pages.

I want to know the position of the last line of text on the last page. Is this possible?

I need to store this value for later for adding digital signatures shortly under the last line of text. Thanks!


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 21, 2013 9:16 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!

Placeholders are on the wishlist, but not yet available in MigraDoc - placeholders that can be filled using PDFsharp after MigraDoc made its rendering.

Look here for GetRenderInfoFromPage:
viewtopic.php?p=1960#p1960

You can add a Tag to your last paragraph so you can find it in the final document.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 25, 2013 5:15 am 
Offline

Joined: Thu Feb 21, 2013 2:57 am
Posts: 3
Thanks for pointing me in the right direction!

The question I have now is how do I access the .Top property of the rendered object? ie. after i have rendered the document and I grab the object, for example:
Code:
// commented out for brevity
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
List<DocumentObject> docObjects = renderer.DocumentRenderer.GetDocumentObjectsFromPage(lastPage).ToList();

var lastObject = (MigraDoc.DocumentObjectModel.Tables.Table)docObjects.Last();
lastObject. // how to access the position from the top of this object?



Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 25, 2013 9:18 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
You have to use "GetRenderInfoFromPage", not "GetDocumentObjectsFromPage".

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 25, 2013 4:17 pm 
Offline

Joined: Thu Feb 21, 2013 2:57 am
Posts: 3
For others looking to do this:

1) download source code, alter the classes Thomas mentions to be public instead of internal
2) rebuild, and add the build DLL's (i was only able to get it to build in debug mode, fine for my use though)

3) then in your code
Code:
renderer.RenderDocument();

// whatever else you do...

var stuff = renderer.DocumentRenderer.GetRenderInfoFromPage(resolucionLastPage);
var topBoundary = stuff.Last().LayoutInfo.ContentArea.Y; // or cylce through the objects till you find the one u want
var pageHeight = renderer.DocumentRenderer.FormattedDocument.GetPageInfo(resolucionLastPage).Height;



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 64 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