How to get and change PDF metadata in Linux

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
How to get and change PDF metadata in Linux
How to get and change PDF metadata in Linux
Software Requirements and Linux Command Line Conventions
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 sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to get and change PDF metadata from GUI



Twitter icon Follow LinuxConfig.org on Twitter for the latest tips and tricks about Linux!


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.

  1. You can see our other tutorial on Master PDF Editor Linux Installation to get the application on your system.
  2. In Master PDF Editor, navigate to File > Properties.
    Open the Properties menu
    Open the Properties menu
  3. Under the Document Info tab, you will see all of the metadata for your PDF file.
    Viewing PDF metadata in Master PDF Editor
    Viewing PDF metadata in Master PDF Editor
  4. 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.

To install ExifTool on Ubuntu, Debian, and Linux Mint:

$ sudo apt install libimage-exiftool-perl

To install ExifTool on Fedora, CentOS, AlmaLinux, and Red Hat:



$ sudo dnf install perl-Image-ExifTool

To install ExifTool on Arch Linux and Manjaro:

$ sudo pacman -S perl-image-exiftool
  1. To view all of the metadata for a PDF file, use the exiftool command and specify the name of your PDF document.
    $ exiftool document.pdf
    
    Viewing PDF metadata using ExitTool command
    Viewing PDF metadata using ExitTool command
  2. To get a specific piece of metadata, such as the author, specify the option in your command:
    $ exiftool -Author document.pdf 
    Author                          : Canonical
    
  3. 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.

  4. 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
    
  5. To clear the metadata for all fields in the PDF file, use the following syntax.
    $ exiftool -all= document.pdf
    


Closing Thoughts

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.



Comments and Discussions
Linux Forum