PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
Find position of last paragraph text on page http://forum.pdfsharp.de/viewtopic.php?f=2&t=2336 |
Page 1 of 1 |
Author: | jamesr [ Thu Feb 21, 2013 3:04 am ] |
Post subject: | Find position of last paragraph text on page |
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! |
Author: | Thomas Hoevel [ Thu Feb 21, 2013 9:16 am ] |
Post subject: | Re: Find position of last paragraph text on page |
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. |
Author: | jamesr [ Mon Feb 25, 2013 5:15 am ] |
Post subject: | Re: Find position of last paragraph text on page |
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? |
Author: | Thomas Hoevel [ Mon Feb 25, 2013 9:18 am ] |
Post subject: | Re: Find position of last paragraph text on page |
You have to use "GetRenderInfoFromPage", not "GetDocumentObjectsFromPage". |
Author: | jamesr [ Mon Feb 25, 2013 4:17 pm ] |
Post subject: | Re: Find position of last paragraph text on page |
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; |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |