PDFX empowers you to merge, split, extract and remove PDF pages right in your terminal.
- Merge all PDF files in a directory into one file
- Split a PDF into two files at a specified page number
- Extract specified pages from a PDF and merge them into a new file
- Remove specified pages from a PDF and save the result to a new file
- Check version via
pdfx versionorpdfx -v - Color-coded output for easy operation feedback
Make sure Go is installed and environment variables are set:
go versiongit clone https://github.com/bryantaolong/pdfx.git
cd pdfxgo build -o pdfx.exego build -o pdfxOptional: Add the executable to your system PATH for global usage.
pdfx --help
pdfx merge --help
pdfx split --help
pdfx extract --help
pdfx remove --helpMerge all PDF files in a directory into one file:
# Merge all PDFs in current directory
pdfx merge --output merged.pdf
# Merge PDFs from a specific directory
pdfx merge -d ./path/to/pdfs -o merged.pdfSplit a PDF into two files at a specified page number:
pdfx split input.pdf --from 10This splits input.pdf into:
input_1-9.pdf(pages 1-9)input_10-56.pdf(pages 10 to end, actual end page depends on input)
Extract specified pages from a PDF and merge them into a new file:
pdfx extract input.pdf --pages 1,3,5 --output extracted.pdfRemove specified pages from a PDF and save the result to a new file:
pdfx remove input.pdf --pages 1,3,5 --output removed.pdf# Check version
pdfx -v
# Merge all PDFs in a directory
pdfx merge -d ./docs -o combined.pdf
# Split a PDF at page 15
pdfx split book.pdf -f 15
# Extract pages 1, 2, and 3
pdfx extract book.pdf -p 1,2,3 -o chapters.pdf
# Remove pages 1, 2, and 3
pdfx remove book.pdf -p 1,2,3 -o remaining.pdfpdfx/
├─ cmd/ # Cobra command modules
│ ├─ root.go
│ ├─ version.go
│ └─ commands/
│ ├─ util.go
│ ├─ merge.go
│ ├─ split.go
│ ├─ extract.go
│ └─ remove.go
├─ test/ # Integration tests
├─ logo/ # Logo assets and icon workflow
├─ main.go
└─ README.md
- Page numbers are 1-based in all commands
- The
--fromflag insplitindicates the start page of the second file - The
--pagesflag inextractaccepts comma-separated page numbers - The
--pagesflag inremoveaccepts comma-separated page numbers to remove - Removing all pages is not allowed and will result in an error