PDF

June 29, 2026 ยท View on GitHub

PDFly

Utility to extract metadata, cut, splice or concatenate PDFs.

https://pdfly.readthedocs.io/en/latest/

brew install pdfly

Extract Metadata

pdfly meta "$name.pdf"

Extract Pages from a PDF

Works like Python list - indices start at zero.

This takes pages 2, 3 and 4 into out.pdf:

pdfly cat input.pdf 1:4 -o out.pdf

Extract the 5th page:

pdfly cat input.pdf 5 -o out.pdf

Concatenate PDFs together

pdfly cat input1.pdf input2.pdf -o out.pdf

Convert Image to PDF

pdfly x2pdf image.jpg -o out.pdf

Convert Text file to PDF

Pandoc

brew install pandoc
pandoc "$name.txt" -o "$name.pdf"

If you get this error:

pdflatex not found. Please select a different --pdf-engine or install pdflatex

then you need to install a Latex distribution like mactex:

brew install --cask mactex

Restart thes shell or run this:

export PATH="/Library/TeX/texbin:$PATH"

or this:

eval "$(/usr/libexec/path_helper)"

and then try again:

pandoc "$name.txt" -o "$name.pdf"

enscript + ps2pdf

brew install enscript ghostscript
enscript "$name.txt" -o - | ps2pdf - "$name.pdf"

textutil

Built in to macOS, but limited styling:

textutil -convert pdf "$name.txt" -output "$name.pdf"