Skip to main content

PDFEngines.split

Splits PDFs using Gotenberg’s split route:
import { PDFEngines } from "chromiumly";

const buffer = await PDFEngines.split({
  files: ["path/to/file_1.pdf", "path/to/file_2.pdf"],
  options: {
    mode: "pages",
    span: "1-2",
    unify: true,
  },
});
  • mode"pages" or "intervals"
  • span — Page range string (e.g. "1-2", "1,3,5")
  • unify — When mode is "pages", merge the split results into one PDF
  • flatten — Flatten form fields and annotations in the output
Gotenberg does not validate span when mode is "pages"; validation depends on the engine. See Gotenberg PDF Engines configuration.

Split on Chromium and LibreOffice

Chromium converters and LibreOffice also support a split option on convert() so you can split the generated PDF in the same request:
import { UrlConverter } from "chromiumly";

const buffer = await new UrlConverter().convert({
  url: "https://example.com/",
  split: { mode: "pages", span: "1-2", unify: true },
});
See Chromium options and Reference — types for the Split type.