Pagecraft

merge

Merge PDF

Combine several PDFs into one file, in the order you choose.

Reads
the PDFs to merge — application/pdf, 1 or more
Writes
one file — PDFs
Tool page
/merge-pdf

Example

Put a covering letter in front of a report and hand back one file.

Given

  • letter.pdf — an ordinary PDF of 1 pages
  • report.pdf — an ordinary PDF of 3 pages

From code

            import { loadDocument, runOperation } from '@pagecraft/core';

const letter = await loadDocument({ bytes, name: 'letter.pdf' });
const report = await loadDocument({ bytes, name: 'report.pdf' });

const [output] = await runOperation('merge', [letter, report], {
  filename: 'bundle.pdf',
});
          

From a shell

            pagecraft merge letter.pdf report.pdf --filename bundle.pdf
          

What comes back

One PDF of 4 pages.

This example is run by the test suite. If it stopped being true, the build would fail.

Options

filename--filename

string

Filename

What the merged file will be called.

Default: 'merged.pdf'