Unplanned
Last Updated: 11 Mar 2019 17:39 by ADMIN
Tim
Created on: 19 Nov 2018 20:16
Category: WordsProcessing
Type: Bug Report
3
WordsProcessing: Image with a height bigger than the one available in the page results in additional empty page when converting to PDF

In a DOCX document, the users can define an image which is bigger than the size of the page. When such an image is at the beginning of the document and is converted with PdfFormatProvider, an additional page is added in the result PDF.

Workaround: Check the image and resize it if needed:
foreach (var image in document.EnumerateChildrenOfType<ImageInline>())
{
    var section = image.Paragraph.Parent as Section;
    if (image.Image.Height > section.PageSize.Height - section.PageMargins.Top - section.PageMargins.Bottom)
    {
        var height = section.PageSize.Height - section.PageMargins.Top - section.PageMargins.Bottom - (image.Paragraph.Spacing.SpacingAfter * (image.Paragraph.Spacing.LineSpacing - 0.97));
        image.Image.Size = new System.Windows.Size(image.Image.Width, height);
    }
}


0 comments