Commands to manipulate pdf documents | LinuxGist
This article will provide details on how pdf documents can be manipulated in Linux.
- 1.
pdftk
- 2.
ghostscript
- 3.
pdfseparate
- 4.
pdftops
- 5.
ps2pdf
- 6.
pdfunite
- 7.
pdftohtml
- 8.
pdfcrop
- 9.
pdfinfo
- 10.
pdftoppm
Here are several Linux commands that can be used to manipulate PDF documents:
1. pdftk
pdftk
is a versatile command-line tool for working with PDFs.
Basic Usage:
Merge multiple PDFs:
1
pdftk file1.pdf file2.pdf cat output merged.pdf
Split a PDF into individual pages:
1
pdftk input.pdf burst output page_%03d.pdf
Rotate pages:
1
pdftk input.pdf cat 1-end right rotate=90 output rotated.pdf
Watermark PDFs:
1
pdftk input.pdf background watermark.pdf output watermarked.pdf
2. ghostscript
Ghostscript
is a powerful tool for manipulating and converting PDF files.
Basic Usage:
Convert images to PDF:
1
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.jpg
Combine images into a single PDF:
1
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf image1.png image2.png image3.png
3. pdfseparate
pdfseparate
is part of the Poppler-utils package and can be used to split PDFs.
Basic Usage:
Split a PDF into individual pages:
1
pdfseparate input.pdf output_%02d.pdf
4. pdftops
pdftops
is also part of the Poppler-utils package and can be used to convert PDFs to PostScript files.
Basic Usage:
Convert PDF to PS:
1
pdftops input.pdf output.ps
5. ps2pdf
ps2pdf
is part of the Ghostscript package and can be used to convert PostScript files back to PDFs.
Basic Usage:
Convert PS to PDF:
1
ps2pdf input.ps output.pdf
6. pdfunite
pdfunite
is a command-line tool that concatenates multiple PDFs into one.
Basic Usage:
Merge multiple PDFs:
1
pdfunite file1.pdf file2.pdf output.pdf
7. pdftohtml
pdftohtml
can be used to convert PDFs to HTML.
Basic Usage:
Convert PDF to HTML:
1
pdftohtml input.pdf output.html
8. pdfcrop
pdfcrop
is part of the Tex Live distribution and can be used to crop whitespace from around a PDF.
Basic Usage:
Crop a PDF:
1
pdfcrop input.pdf output.pdf
9. pdfinfo
pdfinfo
can be used to extract metadata from a PDF file.
Basic Usage:
Extract metadata:
1
pdfinfo input.pdf
10. pdftoppm
pdftoppm
is part of the Poppler-utils package and can convert PDFs into various image formats (e.g., PNG, JPEG).
Basic Usage:
Convert PDF to PNG:
1
pdftoppm -png input.pdf output_%02d.png
These commands provide a variety of ways to manipulate and convert PDF documents using command-line tools in Linux.