8 Best Linux PDF Editors [CLI + GUI]
For probably the better part of 15 years, PDF has been the de facto standard for sharing, e-mailing, and printing documents. It is a well-supported format and Linux distributions have been able to read them since forever!
The only problem is while Windows and MacOS machines can easily buy and install Adobe Acrobat Pro, there is no native Linux version. But, there are several good PDF editors available, and I had a go at testing them for you.
For the purposes of this article, I tested a variety of Linux PDF editors. Both open-source and proprietary, with two PDF documents, a PDF generated by Wikipedia, as well as a large PDF from Adobe with many pages and images, in order to see how each program handled them. I also tried comamnd-line tools and I can assure you each of them did really well.
3 Best Linux PDF Editors (CLI)
1. pdftk
pdftk (PDF toolkit) is a command-line tool for manipulating PDF documents. It’s available for Linux, Windows, and macOS platforms. pdftk allows users to merge, split, rotate, encrypt, decrypt, and perform other advanced PDF manipulation tasks. It’s a popular tool among Linux users, especially for batch processing and automating PDF workflows.
Merge PDF documents
pdftk file1.pdf file2.pdf file3.pdf cat output merged.pdf
This will merge file1.pdf
, file2.pdf
, and file3.pdf
into a single PDF file called merged.pdf
.
Rotate PDF documents or pages
pdftk input.pdf cat 1-endS output rotated.pdf
This will rotate all pages in the input PDF file input.pdf
by 180 degrees and save the result as rotated.pdf
. You can adjust the rotation angle as needed.
Protect PDF by Password
pdftk input.pdf output encrypted.pdf owner_pw password
This will encrypt or protect pdf by password of the input PDF file input.pdf
with the owner password password
and save the result as encrypted.pdf
.
Remove PDF password
pdftk input.pdf input_pw password output decrypted.pdf
This will decrypt or remove PDF password of the input PDF file input.pdf
using the password password
and save the result as decrypted.pdf
.
Fill PDF forms with X/FDF Data and/or Flatten Forms
pdftk form.pdf fill_form data.xfdf output filled.pdf
This will fill the PDF form in form.pdf
with the data in data.xfdf
and save the result as filled.pdf
. To flatten the filled form, add the option flatten
at the end of the command.
Generate PDF data stencils from PDF forms
pdftk form.pdf generate_fdf output data.fdf
This will generate a data stencil (in FDF format) for the PDF form in form.pdf
and save it as data.fdf
.
Apply a background watermark or a foreground stamp
pdftk input.pdf stamp watermark.pdf output stamped.pdf
This will apply the PDF file watermark.pdf
as a background watermark on every page of input.pdf
and save the result as stamped.pdf
.
Report PDF metrics, bookmarks, and metadata
pdftk input.pdf dump_data output report.txt
This will extract the metrics, bookmarks, and metadata of input.pdf
and save them in a text file called report.txt
.
Add/update PDF metrics, bookmarks, or metadata
pdftk input.pdf update_info metadata.txt output updated.pdf
This will update the metadata of input.pdf
using the data in metadata.txt
and save the result as updated.pdf
. You can also use update_info_utf8
to update the metadata using UTF-8 encoding.
Attach files to PDF pages or PDF documents
pdftk input.pdf attach_files file1.pdf file2.pdf to_page 3 output with_attachments.pdf
This will attach file1.pdf
and file2.pdf
to page 3 of input.pdf
and save the result as with_attachments.pdf
.
Unpack PDF attachments
pdftk input.pdf unpack_files output attachments
This will extract all attachments from input.pdf
and save them in a directory called attachments
.
Burst a PDF document into single pages
pdftk input.pdf burst output page_%04d.pdf
This will split input.pdf
into individual pages and save them as page_0001.pdf
, page_0002.pdf
, and so on.
Uncompress and re-compress page streams
pdftk input.pdf output uncompressed.pdf uncompress
Apply a background watermark or a foreground stamp
- Apply a background watermark –
pdftk input.pdf background watermark.pdf output output.pdf
- Apply a foreground stamp –
pdftk input.pdf stamp stamp.pdf output output.pdf
Report pdf metrics, bookmarks and Metadata
- Report pdf metrics
pdftk input.pdf dump_data output output.txt
- Report pdf bookmarks
pdftk input.pdf dump_data_utf8 output output.txt
- Report pdf metadata
pdftk input.pdf dump_data output output.txt
Add/update pdf metrics, bookmarks or metadata
- Add metadata
pdftk input.pdf update_info info.txt output output.pdf
- Update bookmarks
pdftk input.pdf update_info_utf8 bookmarks.txt output output.pdf
- Update page labels
pdftk input.pdf update_info_utf8 page_labels.txt output output.pdf
Attach files to pdf pages or pdf documents
- Attach file to a specific page
pdftk input.pdf attach_files attachment.pdf to_page 2 output output.pdf
- Attach file to the entire document
pdftk input.pdf attach_files attachment.pdf output output.pdf
Unpack pdf attachments:
pdftk input.pdf unpack_files
Burst a pdf document into single pages
pdftk input.pdf burst
Uncompress and re-compress page streams / repair corrupted pdf
- Uncompress page streams
pdftk input.pdf output uncompressed.pdf uncompress
- Re-compress page streams
pdftk uncompressed.pdf output recompressed.pdf compress
- Repair a corrupted pdf
pdftk input.pdf output fixed.pdf
(pdftk automatically tries to repair any errors in the input pdf)
Best CMS For 2023
If you want to start your own website in 2023, there are many easy ways to do so with the help of one of these CMS, or content management systems.
2. pdfunite
pdfunite is a command-line tool for merging multiple PDF documents into a single PDF file. It is a part of the Poppler-utils package, a set of command-line utilities for working with PDF documents based on the Poppler library.
With pdfunite, users can easily combine multiple PDF documents, rearrange their order, and create bookmarks for the resulting document. pdfunite is available on various operating systems, including Linux, macOS, and Windows, and it supports various PDF formats, including encrypted and password-protected documents. It is a powerful and convenient tool for merging PDF files and can be easily integrated into scripts and automated workflows.
Merge PDF documents
To merge two or more PDF documents, use the following command –
pdfunite inputfile1.pdf inputfile2.pdf outputfile.pdf
3. ghostscript
Merge PDF documents
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf file1.pdf file2.pdf file3.pdf
This command merges file1.pdf
, file2.pdf
and file3.pdf
into a single PDF named merged.pdf
.
Rotate pdf documents or pages
gs -o rotated.pdf -sDEVICE=pdfwrite -c "[/Rotate 90] setpagedevice" -f input.pdf
This command rotates all pages in input.pdf
90 degrees clockwise and saves the output as rotated.pdf
.
To rotate a specific page, replace the [/Rotate 90]
in the command above with << /Rotate 90 /PageNum 1 >>
where PageNum
is the page number to rotate.
Encrypt or Protect PDF by Password
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf -c ".setpdfwrite <</Encryption 3>> setdistillerparams" -f input.pdf
This command encrypts or protect PDF by password of input.pdf
with standard 128-bit AES encryption and saves the output as output.pdf
. The user will be prompted for a password when opening the document.
Decrypt or Remove PDF Password
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf -c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams" -f input.pdf
This command removes encryption from input.pdf
and saves the output as output.pdf
.
Fill PDF Forms with X/FDF Data and/or Flatten Forms
gs -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf -dPDFFitPage -dPDFSETTINGS=/prepress -f input.pdf input_data.xfdf
This command fills the form fields in input.pdf
with data from input_data.xfdf
and saves the output as output.pdf
. To flatten the form fields and make them uneditable, add -dNeedAppearances=true
to the command.
Generate PDF data stencils from PDF forms
gs -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf -dPDFSETTINGS=/prepress -f input.pdf -c "[ /Title (Data stencil) /PageMode /UseAttachments << /EmbeddedFiles [ (input_data.xfdf) ] >> >> setdistillerparams"
This command creates a PDF data stencil by attaching input_data.xfdf
as an embedded file to input.pdf
and saves the output as output.pdf
.
Apply a background watermark or a foreground stamp
gs -o stamped.pdf -sDEVICE=pdfwrite -c "30 30 moveto /Helvetica findfont 12 scalefont setfont (SAMPLE WATERMARK) show" -f input.pdf
This command adds a background watermark to input.pdf
with the text “SAMPLE WATERMARK” at position (30,30) using the Helvetica font. To add a foreground stamp, use the overlay
device instead of pdfwrite
.
Report pdf metrics, bookmarks and Metadata
gs -q -dNODISPLAY -c "input.pdf (w) file runpdfbegin pdfdict /Root get /Metadata get == quit"
This command displays the metadata of input.pdf
.
- To display the bookmarks, use –
gs -q -dNODISPLAY -c "input.pdf (w) file runpdfbegin pdfmark /Subtype /Document /OUT pdfmark"
This command displays the bookmarks of input.pdf
.
- Add/update pdf metrics, bookmarks or metadata –
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -o output.pdf -c "[ /Title (Document Title) /Author (Author Name) /Subject (Document Subject) /Keywords (Keyword1 Keyword2 Keyword3) /DOCINFO pdfmark" -f input.pdf
This command updates the metadata of input.pdf
with the title “Document Title”, author “Author Name”, subject “Document Subject”, and keywords “Keyword1 Keyword2 Keyword3”. The output PDF is saved as output.pdf
.
- To add a bookmark to a specific page, use –
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -o output.pdf -c "[ /Title (Bookmark Title) /Page 2 /DEST [ 0 /FitH 300 ] /OUT pdfmark" -f input.pdf
This command adds a bookmark titled “Bookmark Title” that points to page 2 and scrolls to a horizontal position of 0 and a vertical position of 300. The output PDF is saved as output.pdf
.
Attach files to pdf pages or pdf documents:
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -o output.pdf -c "[ {Catalog} << /Names [(Attachment) << /EmbeddedFiles [ (attachment.pdf) ] >> ] >> /PUT pdfmark" -f input.pdf
This command attaches attachment.pdf
to input.pdf
as an embedded file and saves the output as output.pdf
.
To attach a file to a specific page, replace {Catalog}
in the command above with [{PageNum} 0 obj << /Names [(Attachment) << /EmbeddedFiles [ (attachment.pdf) ] >> ] >> /AP pdfmark]
where PageNum
is the page number to attach the file to.
Unpack pdf attachments
gs -q -dNODISPLAY -c "input.pdf (r) file runpdfbegin pdfdict /Root get /Names get { /Type /EmbeddedFile eq { /F (output.pdf) currentfile << /Filter /FlateDecode >> /FLATEDECODE filter /SubFileDecode filter cvx /ASCIIHexDecode filter cvx } { pop null } ifelse } forall quit"
This command extracts all attachments in input.pdf
to individual files with their original names and saves them in the current directory.
Burst a pdf document into single pages
gs -sDEVICE=pdfwrite -o output_%d.pdf -dBATCH -dNOPAUSE input.pdf
This command burst the input.pdf
into individual PDF files with the naming convention output_1.pdf
, output_2.pdf
, etc.
Uncompress and re-compress page streams
gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dDetectDuplicateImages=true -dCompressFonts=true -dCompressPages=true -dPrinted=false -sOutputFile=output.pdf input.pdf
This command uncompresses the page streams in input.pdf
, and then re-compresses them using the settings specified by -dPDFSETTINGS
. The output is saved as output.pdf
.
Split PDF documents into separate pages or sections
gs -sDEVICE=pdfwrite -dSAFER -o output_%d.pdf -dFirstPage=1 -dLastPage=5 -dBATCH -dNOPAUSE input.pdf
This command splits the input.pdf
into individual PDF files with the naming convention output_1.pdf
, output_2.pdf
, etc., with each file containing pages 1-5.
To split the PDF into sections, you can use the same command and specify a range of pages for each section using -dFirstPage
and -dLastPage
.
Rotate individual pages in a PDF document
gs -o output.pdf -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -c "<</Orientation 3>> setpagedevice" -f input.pdf
This command rotates all pages in input.pdf
by 180 degrees, effectively flipping them upside down. The output is saved as output.pdf
.
To rotate a specific page, replace << /Orientation 3>>
with the desired rotation angle in degrees, and add the page range using -dFirstPage
and -dLastPage
.
Decrypt and encrypt individual PDF files
gs -o output.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf -sOwnerPassword=ownerpassword -sUserPassword=userpassword -c .setpdfwrite -f input.pdf
This command encrypts input.pdf
using the owner password “ownerpassword” and user password “userpassword”. To decrypt the file, you can use the same command but omit the password options.
Stamp a watermark or text onto a PDF document
gs -o output.pdf -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -c "30 750 moveto /Arial-Bold findfont 48 scalefont setfont (CONFIDENTIAL) showpage" -f input.pdf
This command adds a watermark to input.pdf
that says “CONFIDENTIAL” in Arial Bold font at position (30,750) on the page. The output is saved as output.pdf
.
Fill out PDF forms with user-provided data
gs -o output.pdf -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dPDFFitPage -dFirstPage=1 -dLastPage=1 -c "<< /AcroForm (/job-application.pdf) /Fields [ << /T (name) /V (John Doe) >> << /T (email) /V (johndoe@example.com) >> ] >> setpdfwrite" -f input.pdf
This command fills out a PDF form with the field “name” set to “John Doe” and “email” set to “johndoe@example.com“. The form is located in the file “job-application.pdf”. The output is saved as output.pdf
.
Flatten filled-out PDF forms to make them uneditable
gs -o output.pdf -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dPDFFitPage -dFirstPage=1 -dLastPage=1 -c "true 1 /FL flattenpath fill setpdfwrite" -f input.pdf
This command flattens the form fields in input.pdf
so that they cannot be edited. The output is saved as output.pdf
.
Extract specific pages or sections from a PDF document
gs -o output.pdf -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dPDFFitPage -dFirstPage=3 -dLastPage=5 -f input.pdf
This command extracts pages 3-5 from input.pdf
and saves them as output.pdf
. You can also specify a range of pages using -dPageRange
. To extract a specific section, you can combine the extract and merge commands, as shown in the previous examples.
Merge multiple PDF files into a single document with bookmarks
gs -o output.pdf -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.4 -c "[ /Title (Merged PDF) /OUT pdfmark" -f file1.pdf file2.pdf file3.pdf
This command merges file1.pdf
, file2.pdf
, and file3.pdf
into a single PDF file output.pdf
. It also adds a bookmark with the title “Merged PDF”.
Repair corrupted PDF files
gs -o output.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -sOutputFile=output.pdf -f input.pdf
This command attempts to repair a corrupted input.pdf
file and save the output as output.pdf
. It uses the PDFSETTINGS and CompatibilityLevel options to ensure the output file is compatible with most PDF readers.
Compress and uncompress PDF files
gs -o output.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/screen -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -sOutputFile=output.pdf -f input.pdf
This command compresses input.pdf
using the /screen PDFSETTINGS option and saves the output as output.pdf
. To uncompress a PDF file, use the /prepress or /printer option instead.
Create a table of contents (TOC) for a PDF document
gs -o output.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -sOutputFile=output.pdf -c "[/Title (Table of Contents) /OUT pdfmark [/Page 1 /Title (Chapter 1) /OUT pdfmark] [/Page 5 /Title (Chapter 2) /OUT pdfmark]]" -f input.pdf
This command creates a table of contents for input.pdf
with two entries: “Chapter 1” on page 1 and “Chapter 2” on page 5. It saves the output as output.pdf
. You can add more entries by adding additional /Page
and /Title
options to the pdfmark command.
5 Best Linux PDF Editors (GUI)
1. LibreOffice Draw
Most Linux distributions these days come with LibreOffice pre-installed. For those that don’t have LibreOffice installed, one can easily install it from software center. Best of all, for the past few years or so, LibreOffice’s Draw component has been able to import and edit PDFs!
LibreOffice Draw did a reasonably good job at importing the Wikipedia-generated PDF. It wasn’t perfect – far from it – but it was readable. The large PDF with all the images was a struggle, unfortunately. Draw struggled so much that it hung each time and I was unable to open and edit that PDF at all. The good news, however, is that Draw does a very good job at importing PDFs created by office suites like Microsoft Office and LibreOffice. I have done so very successfully in the past. Thus, in many use-cases, Draw could probably work just fine!
2. Inkscape
Inkscape is a really well-rounded vector graphics program, and it is used by graphic design professionals all around the world daily. I highly recommend it for such work, and best of all, it can import and edit PDFs! So perhaps should work well as a Linux PDF editor. Let’s see!
It was able to import both test documents very well and incredibly accurately. The only thing that might bother some people is that Inkscape is not a multi-page document editor, like Word or LibreOffice Draw. So it only imports one page at a time. That hasn’t bothered me, however, in the past I have edited many PDF’s page-by-page, just putting all the pages together again afterward with a tool like pdftk.
3. Master PDF Editor
The first proprietary application on this list, Master PDF Editor is an almost perfect drop-in replacement for Adobe Acrobat Pro. It runs on Linux, Windows, and Mac, and has commercial support.
It was able to flawlessly (as far as I could see) import any PDF I could throw at it, including things like annotations and fonts. I was able to edit as much as I wanted. This is a quality product and, in my opinion, if you decide to buy it, it is money well spent.
4. Qoppa PDF Studio 11
The second proprietary application on this list, and also a paid option, PDF Studio 11 also appears to be written to be a full replacement for Adobe Acrobat Pro, like Master. It is also a mature application with commercial support.
The Pro version has all the features that Adobe Acrobat Pro and Master have as far as I can see. It opened the test documents just as flawlessly as Master PDF Editor did. This is also a quality product and will probably suit you well if you decide to buy it.
5. PDF Chain
This list would not be complete without mentioning the pdftk tool and the best Linux graphical frontend for it, PDF Chain.
This is a simple but powerful application, but it is not a full-blown graphical editor as the other applications listed here – its usefulness lies elsewhere. It can split a PDF into smaller documents, or merge two into one. It can add backgrounds, stamps, or edit the PDF info, or dump the form data in a PDF, among the many things it can do.
All in all, a really great application if you don’t want to edit the text or images in a PDF. I highly recommend it.
Conclusion
So, which is one of these applications better than the others? Well, I suppose it depends on what you want to do. Do you just want to edit a word or image in a PDF that someone created in Microsoft Word? You will probably do great with LibreOffice Draw or Inkscape.
Do you want to use something similar to Adobe Acrobat Pro, and be able to fully edit almost all PDF’s in any way you want? You might have to buy a Master or PDF Studio 11. Do you want to merge two PDF documents in one? You should try PDF Chain (or pdftk if you prefer the command line).
These are all in their own right good PDF editors – you just need to choose which one will suit you best. If it doesn’t work for you, try another!