PDFsharp
PDFsharp copied to clipboard
Overflowing paragraph text in TextFrame is not fully visible in end of page
Expected Behavior
Last line in page should be fully visible (see attached pdf file).
Actual Behavior
Half of last line in end of first page is visible.
Steps to Reproduce the Behavior
Run attached solution
Code:
static Document CreateDocument()
{
// Create a new MigraDoc document.
var document = new Document { };
// Add a section to the document.
var section = document.AddSection();
section.PageSetup.BottomMargin = 0;
section.PageSetup.TopMargin = 0;
for (int p = 1; p < 100; p++)
{
var textFrame = section.AddTextFrame();
textFrame.RelativeVertical = RelativeVertical.Line;
textFrame.WrapFormat.DistanceTop = Unit.FromCentimeter(0.11);
textFrame.Height = Unit.FromCentimeter(0.47);
var paragraph = textFrame.AddParagraph();
paragraph.Format.Font.Name = "Times New Roman";
paragraph.Format.Font.Size = 10;
paragraph.AddText("Maksekorraldus 123456");
paragraph.Format.SpaceBefore = 0;
paragraph.Format.SpaceAfter = 0;
}
return document;
}
texttruncatedinendofpage.zip actual behaviour.pdf
Using PDFsharp-MigraDoc 6.0.0-preview-3
Textframes do not break to the next page, this is by design. Callers must ensure that a textframe fits onto the page.
MigraDoc should add page break before such textframe. This issue occurs since paragraph inside textframe stretches to two lines but textframe height is only single line.
MigraDoc should add page break before such textframe.
The software architect of MigraDoc decides what MigraDoc should do. I'll ask him about it.
PDFs are created from report template which contains text fields having left, height, width and top properties:
Paragraph does not have position and size. So text is added to paragraph inside TextFrame. Paragraph contains variable number of lines and has variable height. Page break should inserted if top position + height is greater that printable area in page.
If textFrame is not used, it is not possible to specify paragraph width.
There are no method to get stretched paragraph height. If paragraph height is known, TextFrame height can set to this value and non-floating TextFrames are probably paged correctly.