This utility adds page numbers to a PDF file.
This project uses pnpm as a package manager. To install the dependencies, run:
pnpm install
This project uses Typescript as a language. Typescript must be transpiled with tsc
before it can be run. Install typescript and run tsc
to transpile the typescript to javascript. This is automatically
done by the test
and compile
scripts. Your IDE may also have some auto-transpile functionality for when you're editing
the code. Javascript is transpiled to the dist
directory.
This project uses pkg to compile the script into a binary. To compile the script, run:
pnpm run compile
This will compile binaries for MacOS x64, MacOS ARM, and Windows x64 to the dist/bin
directory.
The script takes in below parameters in order to embed page numbers directly onto a PDF and return the resulting PDF.
--src
: Path to the PDF that will be paginated
--out
: Path to where the script will save the output PDF
--color
: Color of the page numbers. Defaults to black. Accepts any hex value in the format #rrggbb
.
--size
: Size of the page numbers. Defaults to 8. Accepts any integer.
--bottom
: Distance from the bottom of the page to the bottom of the page number. Defaults to 30. Accepts any integer.
--right
: Distance from the right of the page to the right of the page number. Defaults to 50. Accepts any integer.
pnpm run test -- --src=samples/source.pdf --out=samples/output.pdf
./dist/bin/pdf-number-pages-macos-arm64 --src=samples/sample-source.pdf --out=samples/out-bin-arm.pdf
Compiled CLI executable with options:
./dist/bin/pdf-number-pages-macos-arm64 --src=samples/sample-source.pdf --out=samples/output.pdf --bottom=200 --right=200 --color=#ff0000 --size=24