Adding Margins to PDF Pages Using JavaScript

It’s possible to individually add margins to multiple document pages using the addPageMargins document operation.

This feature is only available to customers who have purchased the Document Editor component. If you want to try it, please get in touch with our Sales team.

How to Add Margins to Pages Using the Programmatic API

You can use PSPDFKit.Instance#applyOperations to add margins to PDF document pages:

await instance.applyOperations([
  {
    type: "addPageMargins",
    pageIndexes: [1, 2],
    rect: new PSPDFKit.Geometry.Inset({
      left: 10,
      top: 10,
      right: 10,
      bottom: 10
    })
  }
]);

If you omit the pageIndexes property from the code above, all the PDF document’s pages will have their margins modified.