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

PdfSharpCore/MigraDocCore programmatically position paras?
http://forum.pdfsharp.de/viewtopic.php?f=2&t=4519
Page 1 of 1

Author:  matt_pdf [ Thu Dec 07, 2023 4:35 am ]
Post subject:  PdfSharpCore/MigraDocCore programmatically position paras?

Hi everyone,

I'm in a bit of a conundrum at the moment with PdfSharpCore and MigraDocCore.

I'm trying to create a PDF service that may require the usage of multiple paragraphs that will vary in height due to varying text input length.

Due to MigraDocCore needing me to call "RenderObject" which requires a Y-axis value in order to work, I believe that I need to find a way to programmatically position each paragraph underneath each other to avoid overlap/be able to dynamically adjust positioning due to varying provided text length.

I am currently trying to calculate this via getting the previous paragraphs layout information, via the "GetRenderInfoFromPage" method and then
calculating a "Y-axis" position by adding the previous paragraphs "LayoutInfo.ContentArea.Y.Presentation" and "LayoutInfo.ContentArea.Height.Presentation" together. I provide that to the MigraDocCore renderer "RenderObject" method as the Y-axis value.

I thought that the Y position and the height of the previous paragraphs would result in the next render point would be the bottom of the previous paragraph at the very least. However if a paragraph has a few "\n" the next paragraph would be rendered only toward the bottom of the first paragrah.
Attachment:
File comment: This snip shows the overlap - the second paragraph is overlapping the bottom of the first paragraph
ParagraphOverlap.PNG
ParagraphOverlap.PNG [ 40.65 KiB | Viewed 7401 times ]


I am aware of the "SpaceBefore" and "SpaceAfter" properties on paragraphs, however those are irrelevant due to the required usage of "RenderObject" which requires a Y-axis value.

TLDR:
Has anyone figured out a way to programmatically position paragraphs underneath each other with PdfSharpCore and MigraDocCore?

Thanks so much for any help

Author:  TH-Soft [ Thu Dec 07, 2023 8:41 am ]
Post subject:  Re: PdfSharpCore/MigraDocCore programmatically position para

matt_pdf wrote:
I'm in a bit of a conundrum at the moment with PdfSharpCore and MigraDocCore.
We do not support those libraries here.
Feel free to try our libraries.

When using RenderObject, you are fully responsible for object positions and it is up to your to code to prevent overlapping.

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