PDF metadata contains information like author, subject, creator, producer, and keywords. This information is embedded into the PDF file itself, and can be retrieved if a user needs to determine who released the document, or wants to see what application was used to create it, etc. The keywords can also help organize PDF documents by category in case you have a lot of PDF files.
In this tutorial, you will see how to get and change PDF metadata on a Linux system. This can be accomplished from both command line and GUI. We will cover both methods below.
In this tutorial you will learn:
- How to get and change PDF metadata from GUI
- How to get and change PDF metadata from command line
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Software||Master PDF Editor, ExifTool|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to get and change PDF metadata from GUI
Any PDF editor should have the ability to get and change metadata of the file. One such example is the Master PDF Editor, which is available for free on Linux.
- You can see our other tutorial on Master PDF Editor Linux Installation to get the application on your system.
- In Master PDF Editor, navigate to File > Properties.
- Under the Document Info tab, you will see all of the metadata for your PDF file.
- If you want to change any of this metadata, just make your edits in this window, then press OK to save it. The new metadata will be written to the PDF file. To remove the metadata, just backspace the contents here and press OK.
How to get and change PDF metadata from command line
ExifTool is a command like program which can get and change PDF metadata. You can use the appropriate command below to install ExifTool with your system’s package manager.
$ sudo apt install libimage-exiftool-perl
$ sudo dnf install perl-Image-ExifTool
$ sudo pacman -S perl-image-exiftool
- To view all of the metadata for a PDF file, use the
exiftoolcommand and specify the name of your PDF document.
$ exiftool document.pdf
- To get a specific piece of metadata, such as the author, specify the option in your command:
$ exiftool -Author document.pdf Author : Canonical
- To change the metadata for a field, use the following command syntax. This will change the Author field.
$ exiftool -Author="linuxconfig" document.pdf 1 image files updated
The output says an image file has been updated, since ExifTool is primarily used to work with images, but do not worry, it will also make changes to the PDF document.
- To clear the metadata for a field, just overwrite it with empty data. Here is how we would delete the Subject field.
$ exiftool -Subject= document.pdf 1 image files updated
- To clear the metadata for all fields in the PDF file, use the following syntax.
$ exiftool -all= document.pdf
In this tutorial, we saw how to get and change PDF metadata on a Linux system. This included a GUI method with Master PDF Editor and a command line method with ExifTool. Keep in mind that completely clearing metadata from PDF files can be tricky, and the old metadata can often be recovered.