How to get and change PDF metadata on Linux using the terminal

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. In this post, I will show you How to get and change PDF metadata on Linux using the terminal. So, you can quickly use it for a specific case or several files. You can even include it in scripts.

Is this really useful?

The reality is yes. Many times in configuration scripts we can include various commands to automate processes, and file management is no exception.

Besides this, it is always useful to have the terminal at hand, since it is faster and more efficient than in a graphical interface. Moreover, this will ensure that it will work in almost any environment.

So, let’s get started.

Install necessary packages

To perform the task, we need a tool called exiftool with which we can edit the metadata of a PDF file without major problems.

In the case of Debian, Ubuntu, Linux Mint and other members of the family, you can install it with this command:

sudo apt install libimage-exiftool-perl

If you are using Fedora, CentOS, RHEL, or Rocky Linux then you have to run:

sudo dnf install perl-Image-ExifTool

For Arch Linux based distirbutions

sudo pacman -S perl-image-exiftool

Once you have the package installed, you can continue with the post.

Getting and changing PDF metadata on Linux using the terminal

If you want to get the metadata of any PDF file, you can run

exiftool [PDF-File]

Of course, you can use relative and absolute paths to get the results.

exiftool sample.pdf
Getting the PDF metadata
Getting the PDF metadata

Note: For this post i used an sample PDF file from here

If you would like to get only an extract of this metadata, you can do it as follows

exiftool -Creator sample.pdf

This means that the output screen will only show the author of the document.

Creator                         : Rave (http://www.nevrona.com/rave)

It can also be other metadata

exiftool -Keywords sample.pdf

In case you want to change some metadata, say the Creator.

exiftool -Creator="Unixcop" sample.pdf

Also if a metadata is not specified, you can add it with the above syntax. For example, I will add Author.

exiftool -Author="Unixcop" sample.pdf
Setting the PDF metadata
Setting the PDF metadata

So the syntax is simple, just define the metadata and specify the new value.

If you want to simply remove a metadata, then leave it blank

exiftool -Author= document.pdf

It’s that simple.

But it is possible to clear them all

exiftool -all= document.pdf

Then all metadata will be blank.

That’s all.

Conclusion

In this post, you learned an important part of manipulating PDF files. I hope you liked it.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook