PDF toolkit — manipulate PDF documents (extract pages, merge, rotate, dump metadata and text)

Synopsis

pdftk <input.pdf> <operation> [args...]

pdftk A=<one.pdf> B=<two.pdf> cat A B output <merged.pdf>

Description

A browser-native reimplementation of the classic pdftk command for SLICC. It operates on PDF files stored in the SLICC virtual filesystem using @cantoo/pdf-lib for page manipulation and unpdf for text extraction. No server or native binary is required — everything runs in the browser.

Operations

dump_data Print PDF metadata: page count, title, author, creator, and producer.

dump_data_utf8 Extract text content from the PDF (all pages).

cat <ranges...> output <output.pdf> Extract, rearrange, or merge pages into a new PDF.

rotate <ranges...> output <output.pdf> Rotate pages in a PDF. A rotation suffix is required on each range.

Page Ranges

3 Single page

1-5 Range of pages

3-end From page 3 to the last page

1-endright Pages 1 to end, rotated 90 degrees clockwise

3left Page 3 rotated 270 degrees (counterclockwise)

1-5down Pages 1-5 rotated 180 degrees

Options

-h, --help Show help message

Merge Syntax

Assign single-letter handles to input files, then reference them in the cat ranges:

pdftk A=one.pdf B=two.pdf cat A B output merged.pdf

Examples

$ pdftk in.pdf dump_data

Print page count, title, author, and other metadata.

$ pdftk in.pdf dump_data_utf8

Extract all text content from the PDF.

$ pdftk in.pdf cat 1-3 output out.pdf

Extract pages 1 through 3 into a new file.

$ pdftk in.pdf cat 1 3-end output out.pdf

Extract page 1 and pages 3 to end.

$ pdftk in.pdf rotate 1-endright output out.pdf

Rotate all pages 90 degrees clockwise.

$ pdftk A=one.pdf B=two.pdf cat A B output merged.pdf

Merge two PDFs into one.

Notes

This is a browser-native subset of the real pdftk. It supports dump_data, dump_data_utf8, cat, and rotate operations. Features like stamp, burst, fill_form, encryption, and other advanced operations from the native tool are not implemented. The dump_data operation only supports a single input file. Rotation is additive — it adds to any existing page rotation.

See Also

cat, convert