0
votes

I am using PDFsharp and MigraDoc to create PDF documents. And yesterday I faced with problem of page ending. I have a loop with data for example for 10 items. In each iteration I need to create such document -> pdf example

And then save it as one PDF document. As we see I have several blocks on the page which can dynamically increase. How can I detect ending of the page end continue draw string on next page? And how can I detect ending of a first paragraph to add second (or just attach to the end)? I tried use paragraph.AddText() and it doesn't continue on the next page, just go into nowhere. From documentation of PDFsharp and MigraDoc I can’t find correspondent example. Here is my attempts to do it for one iteration download example, example 2 download. I will be very grateful for some pieces of code which can help me.

1

1 Answers

1
votes

You do not show any code. You mention AddText() so I assume you use MigraDoc.

The MigraDoc samples can be found here:
http://www.pdfsharp.net/wiki/MigraDocSamples.ashx

With MigraDoc you normally do not have to care about page breaks as MigraDoc will break paragraphs to the next page automatically. At least this is the default behavior when you use renderer.RenderDocument() to create the document.
You can use Section.AddPageBreak() to force a page break when needed.

See this example for recommended use of MigraDoc and RenderDocument():
http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx