Add Margins to PDF Pages

Add margins to PDF pages

The Java sample adds 36-point margins to pages 1 and 3 of the source document.

Steps

  1. Create a PdfFileEditor instance.
  2. Select the page numbers that should receive new margins.
  3. Call addMargins with the input file, output file, page list, and margin values.
  4. Save the updated PDF.

Java example

public static void addMarginsToPdfPages(Path inputFile, Path outputFile) {
    PdfFileEditor pdfEditor = new PdfFileEditor();
    pdfEditor.addMargins(inputFile.toString(), outputFile.toString(), new int[] {1, 3}, 36, 36, 36, 36);
}