pdfcpu

Logo

PDF tooling for Go and the command line.

View the Project on GitHub pdfcpu/pdfcpu


Changelog
Future Directions

Import Bookmarks

This command imports bookmarks via JSON.

Either import a modified JSON structure generated by pdfcpu bookmarks export or use one as a template for this command.

Have a look at some examples.

Usage

pdfcpu bookmarks import inFile inFileJSON [ outFile ] [flags]

Flags

namedescriptionrequireddefault
replaceenable replacing existing bookmarksnofalse

Common Flags


Arguments

namedescriptionrequired
inFilePDF input file, use - to read from stdinyes
inFileJSONJSON input fileyes
outFilePDF output file, use - to write to stdoutno

Description

A bookmark is a node in the so called Outline tree of a PDF file. Each bookmark may have kid nodes representing the bookmark hierarchy below:

attributedescriptiontyperequired
titletitleUTF-8 stringyes
pagedestination pageintyes
colorRGB colortriple of floatsno
boldstyle boldboolno
italicstyle italicboolno
kidsbookmark subtreebookmark arrayno

Note: color, bold and italic are not supported by Mac Preview!

Examples

$ pdfcpu bookmarks import bookmarkTree.pdf bookmarkTree.json
pdfcpu: existing outlines

pdfcpu bookmarks import bookmarkTree.pdf bookmarkTree.json --replace

$ pdfcpu bookmarks list bookmarkTree.pdf
Page 1: Level 1
    Page 2: Level 1.1
    Page 3: Level 1.2
        Page 4: Level 1.2.1
Page 5: Level 2
    Page 6: Level 2.1
    Page 7: Level 2.2
    Page 8: Level 2.3

Import bookmarks while reading the PDF from stdin:

$ aws s3 cp s3://acme-manuals/product.pdf - \
   | pdfcpu bookmarks import --replace - bookmarks.json - \
   | aws s3 cp - s3://acme-manuals/product-bookmarked.pdf