PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Rendering to PDF endless loop
https://forum.pdfsharp.net/viewtopic.php?f=3&t=3544
Page 1 of 1

Author:  dabev [ Tue Feb 21, 2017 11:50 am ]
Post subject:  Rendering to PDF endless loop

I create a Migradoc document that repesent one of the output of my application. If I render to RTF, it works fine, when I render the same to PDF it doesn't, Migradoc enters in an endless loop (I debugged a few the source code - If can be useful, it loops on object IDX 23 on the second page, that is an image - and it loops trying to create every time new page). Apparently that is nothing strange in the document and the same image, used in another document works fine causing the page break if needed.
I exported the documenti in mdddl format and, using the sample DocumentViewer, do the same during document rendering.
I tried to change the Image dimension and, if I set it to very small (less than 12 cm of height, but the space on the page should be enough... it just has to break to new page...) it works, otherwise goes in loop.

I attach a file containing the mdddl and related files used.

Thank you in advance.
Dario

Attachments:
TEST.zip [145.79 KiB]
Downloaded 163 times

Author:  Thomas Hoevel [ Tue Feb 21, 2017 2:20 pm ]
Post subject:  Re: Rendering to PDF endless loop

Hi!

Thanks for the feedback.
I can replicate the endless loop, but don't know (yet) how to fix it.

The image that causes the problem:
Code:
    \paragraph
    {
      \image(".\\files\\r6440_81.png")
      [
        Height = "16.1cm"
        Width = "11.73cm"
        LockAspectRatio = true
      ]
      \linebreak
    }

If I remove that "\linebreak" then everything will work just fine.

It is a bug and it should work with all those "\linebreak" in paragraphs.
But maybe it is a quick workaround for you not to use those "\linebreak" statements?

Author:  dabev [ Wed Feb 22, 2017 2:07 pm ]
Post subject:  Re: Rendering to PDF endless loop

First of all, thank you for fast reply.
Yes I could try not using linebreak; If I understood correctly the use of migradoc, I can substitute the \linebreak (I use paragraph.addlinebreak) by adding a new empty paragraph. Is it correct or there is another way to insert an empty line not using linebreak ? (something like paragraph break)


thank you.
Dario

Author:  dabev [ Wed Feb 22, 2017 3:01 pm ]
Post subject:  Re: Rendering to PDF endless loop

I substitute each line break by adding formatting on the following paragrapf (spacebefore ...) and it works.

Thank you and let me know about what asked in previous reply and when this bug correction will be solved and released.

Regards.
dario

Author:  Thomas Hoevel [ Thu Feb 23, 2017 11:59 am ]
Post subject:  Re: Rendering to PDF endless loop

Instead of adding a linebreak at the end of a paragraph, you can do one of the following to get some space:
  • Add an empty paragraph (with SpaceBefore and SpaceAfter set to 0)
  • Set SpaceAfter for the paragraph that previously had the linebreak
  • Set SpaceBefore for the following paragraph

I think having a linebreak at the end of a paragraph can lead to a page with an empty first line. Not desirable.
I think having an empty paragraph can lead to a page with an empty first line. Not desirable either.

Setting SpaceAfter for the paragraph with the image would be my preferred choice.

Author:  dabev [ Thu Feb 23, 2017 4:27 pm ]
Post subject:  Re: Rendering to PDF endless loop

Thank you Thomas,

as I told in my previous post, I solved using "spacebefore" in the succeeding paragraph, that's the same you suggested.

Thank you again and congratulations for the great work you have done with migradoc and PDFsharp.

Dario

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