Different margins with pagination

Hello,

i draw a multiline textelement using

layoutFormat = PdfLayoutFormat(
layoutType: PdfLayoutType.paginate,
breakType: PdfLayoutBreakType.fitPage);

Thats works fine. if the text fit on page1, a second page is created and the text continues on page 2.

But is it possible to set different margings on page1 and page2?
Or ist it possible to draw the text with 
PdfLayoutFormat(
layoutType: PdfLayoutType.onePage,
breakType: PdfLayoutBreakType.fitPage); 

After that i would handle the page break by myself, but then i need the clipped part of the text to draw it on the 2nd page.

Thanks for replies.
Sebastian


10 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team June 30, 2025 11:38 AM UTC

Hi Sebastian,


Currently, it is not possible to set different margins for each page when using the PdfLayoutFormat with PdfLayoutType.paginate. The layout engine applies a consistent layout configuration across all pages during pagination.

Nevertheless, your requirement can be met by setting custom pagination bounds to simulate different margins—such as adding extra space at the top of the second and subsequent pages. This approach allows you to control the layout more precisely during pagination.

Here’s a code example demonstrating how to set the PaginateBounds to leave space at the top of the second page:

PdfGridLayoutFormat format = new PdfGridLayoutFormat();

// Set custom pagination bounds to add top margin on subsequent pages

format.PaginateBounds = new Syncfusion.Drawing.RectangleF(

    0, 15,

    page.GetClientSize().Width,

    page.GetClientSize().Height - 15

);

 

In this example:

  • 15 units of space are added at the top.
  • The height is reduced accordingly to maintain the layout within the page.

Follow the below links for more information:

Changing margins from the second page onwards


Regards,

Irfana J.



CF Christmas Fantasy August 2, 2025 03:17 PM UTC

If I remove the bold styling, it fits 99% of the header values (some of the longer ones still get slightly cut off), but with the bold styling enabled 



IJ Irfana Jaffer Sadhik Syncfusion Team August 5, 2025 12:46 PM UTC

Hi Sebastian,


We were unable to reproduce the issue with the provided details on our end. We request you to share with us the simplified sample to replicate the issue on our end. So that we can assist with you further in this.


Regards,

Irfana J.



EN Eddie Nelson August 11, 2025 07:35 AM UTC

Похоже, что действительно невозможно задать разные поля на первой и последующих страницах при использовании PdfLayoutFormat с типом paginate, но, судя по ответу от команды Syncfusion, можно обойти это, задав собственные границы пагинации

uno online



SE Seraphina May 29, 2026 09:47 AM UTC

@drive mad

Could you clarify how to apply `PaginateBounds` to create space at the top of subsequent pages? 

I'm not sure how to adjust the height to maintain the layout accurately in the PDF document. 

Thank you!



AE Abinaya Eruthayaraj Syncfusion Team June 2, 2026 08:42 AM UTC

Hi @Seraphina,

To introduce top spacing (margin) on subsequent pages when using PdfTextElement.draw, you can utilize the PdfLayoutFormat.paginateBounds property. By default, when content flows onto a new page, it starts at (0, 0) (top-left). Using paginateBounds, you can define the starting position of content on each overflow page.

The following code snippet shows how to apply the paginateBounds property:

PdfDocument document = PdfDocument();
  PdfPage page = document.pages.add();

  double marginTop = 50;
  Size pageSize = page.getClientSize();

  PdfTextElement textElement = PdfTextElement(
    text: 'Your long paragraph text here...' * 20,
    font: PdfStandardFont(PdfFontFamily.helvetica, 12),
  );

  PdfLayoutFormat layoutFormat = PdfLayoutFormat()
    ..layoutType = PdfLayoutType.paginate
    ..paginateBounds = Rect.fromLTWH(
      0,
      marginTop,
      pageSize.width,
      pageSize.height - marginTop,
    );

  textElement.draw(
    page: page,
    bounds: Rect.fromLTWH(
      0,
      marginTop,
      pageSize.width,
      pageSize.height - marginTop,
    ),
    format: layoutFormat,
  )!;

  File('Output.pdf').writeAsBytes(await document.save());
  document.dispose();


Could you please let us know if this explanation helps you create space at the top of subsequent pages?

Regards,
Abinaya E



MC Maria Charles June 18, 2026 09:07 AM UTC

Would you mind clarifying how to utilize PaginateBounds to create a top margin on pages after the first one?

I'm having trouble determining how the height FNAF 4 should be adjusted to keep the PDF layout consistent.



AE Abinaya Eruthayaraj Syncfusion Team June 19, 2026 01:07 PM UTC

Hi Maria Charles,

If we need a top space on the pages, then we should adjust the Y position of the page.

If we need to determine the height of the pages, then we should first set the maximum height available. After that, we need to reduce the top space from that maximum height, and then we can determine the final height to maintain a consistent layout.

Code snippet:

paginateBounds = Rect.fromLTWH(
      0,
      topMargin,
      pageSize.width,
      pageSize.height - topMargin,
    );

Could you please let us know if this explanation helps you determine the final height and maintain a consistent layout?

Regards,
Abinaya E



HD Haven David June 23, 2026 04:43 AM UTC

@Her Trees, I find the explanation about pagination and margins very clear, especially the note that margins are applied consistently across pages and that custom pagination bounds can be used as a workaround.



AE Abinaya Eruthayaraj Syncfusion Team June 23, 2026 12:32 PM UTC

Hi Haven David,

Thank you for your response. Please get in touch with us if you would require any further assistance.

Regards,

Abinaya E


Loader.
Up arrow icon