How to Check PDF Metadata in the Linux Terminal | Baeldung on Linux (2024)

1. Overview

Portable Document Format or PDF is a widely used file format. It’s an open standard maintained by ISO (International Organization for Standardization). It provides a way for exchanging documents that’s independent of software, hardware and operating systems being used.

Besides the content, a PDF file may also contain general information, called metadata, about the document. Sometimes, we may need to inspect this information.

In this tutorial, we’ll discuss how to check the metadata within a PDF document from the command line.

A PDF document consists of a set of PDF objects. The document information dictionary is one of them.

It contains the metadata information about the file. This dictionary stores the metadata information as key-value pairs.

The dictionary contains the following values:

  • Title
  • Subject
  • Keywords
  • Author
  • Creator
  • Producer
  • Creation Date
  • Modification Date

It’s optional to supply values for the keys in the document information dictionary. It’s also possible to add, delete and edit the metadata in a PDF document.

3. Using pdfinfo

We can use the pdfinfo command to print the contents of the document information dictionary of a PDF document. Besides the contents of the dictionary, it also prints other useful information such as page count, page size, PDF version.

Now, we’ll use pdfinfo to examine a PDF document, example.pdf:

$ pdfinfo example.pdfTitle: Introduction to Programming LanguagesKeywords: "C++,Java,Python"Creator: FrameMaker 8.0Producer: Acrobat Distiller 7.0.5 (Windows)CreationDate: Mon Feb 4 10:16:29 2013 ESTModDate: Mon Feb 4 18:00:11 2013 ESTTagged: yesUserProperties: noSuspects: noForm: noneJavaScript: noPages: 58Encrypted: noPage size: 596 x 792 ptsPage rot: 0File size: 544855 bytesOptimized: noPDF version: 1.4

Here, the keys and the corresponding values in the output are self-explanatory.

The page size and page rotation in the output of pdfinfo belongs to the first page. pdfinfo just prints the information of the first page by default if it’s called without any options.

If we want to see the page information of other pages, we can use the -f and -l options:

$ pdfinfo –f 2 –l 3 example.pdfTitle: Introduction to Programming LanguagesKeywords: "C++,Java,Python"Creator: FrameMaker 8.0Producer: Acrobat Distiller 7.0.5 (Windows)CreationDate: Mon Feb 4 10:16:29 2013 ESTModDate: Mon Feb 4 18:00:11 2013 ESTTagged: yesUserProperties: noSuspects: noForm: noneJavaScript: noPages: 58Encrypted: noPage 2 size: 596 x 792 ptsPage 2 rot: 0Page 3 size: 596 x 792 ptsPage 3 rot: 0File size: 544855 bytesOptimized: noPDF version: 1.4

The -f option specifies the first page to examine, while the -l option specifies the last page to examine. Since we passed 2 for the -f option and 3 for the -l option as arguments, pdfinfo printed the page information for these pages.

The unit of page size is in pts. This unit corresponds to a PostScript point. It’s approximately 0.3428 mm.

Another tool we can use is exiftool. It’s a free and open-source tool for reading and writing meta information of a wide variety of files.

It supports many image, audio and video file types. It can also be used for PDF documents.

exif in its name stands for Exchangeable Image File Format.

exiftool comes installed with the perl-Image-ExifTool package.

Let’s use exiftool to examine example.pdf:

$ exiftool example.pdfExifTool Version Number : 12.42File Name : example.pdfDirectory : /home/alice/documentsFile Size : 545 kBFile Modification Date/Time : 2022:10:07 10:15:34+03:00File Access Date/Time : 2022:12:01 08:28:07+03:00File Inode Change Date/Time : 2022:10:07 10:15:34+03:00File Permissions : -rw-r--r--File Type : PDFFile Type Extension : pdfMIME Type : application/pdfPDF Version : 1.4Linearized : NoTagged PDF : YesPage Mode : UseOutlinesXMP Toolkit : 3.1-702Copyright : Example CompanyWeb Statement : www.example.comProducer : Acrobat Distiller 7.0.5 (Windows)Creator Tool : FrameMaker 8.0Modify Date : 2013:02:04 11:00:11-05:00Create Date : 2013:02:04 08:16:29ZMetadata Date : 2013:02:04 11:00:11-05:00Format : application/pdfTitle : Introduction to Programming LanguagesCreator : .Subject : C++,Java,PythonDocument ID : uuid:e5db80e2-4fef-4596-b7a4-bcc15ba1a0daInstance ID : uuid:da74d5f2-b906-4591-bbe6-ce9b0870ab55Page Count : 58Keywords : "C++, Java, Python"Warning : [Minor] Ignored duplicate Info dictionary

The output of exiftool for example.pdf covers the output of pdfinfo. It also has extra fields such as MIME Type, Document ID, etc.

5. Using file

The file command is useful for determining the type of a file. It’s also possible to use file for inspecting some of the properties of a PDF document.

Let’s use file without specifying any options:

$ file example.pdf/home/alice/documents/example.pdf: PDF document, version 1.4

The file is a PDF document, as expected. The output also printed the PDF version, which is 1.4.

The -i option of file provides us the MIME type of a file:

$ file –i example.pdf/home/alice/documents/example.pdf: application/pdf; charset=binary

The MIME type of example.pdf is application/pdf as expected.

6. Conclusion

In this article, we discussed how to check the metadata information of a PDF document from the command line.

Firstly, we learned what PDF metadata is.Then, we discussed the tools we can use for inspecting the PDF metadata.

The first command, pdfinfo, extracts the document information dictionary within a PDF document. It also prints some other additional information.

The second tool we discussed was exiftool, which is a versatile tool used for reading and writing metadata information in a wide variety of files including PDF.

Finally, we saw that the file command gives us the PDF version and MIME type of the document.

How to Check PDF Metadata in the Linux Terminal | Baeldung on Linux (2024)
Top Articles
25 Best Weight Watchers Taco Recipes for Your Next Fiesta
Vegan Broccoli Casserole Recipe
What Is Single Sign-on (SSO)? Meaning and How It Works? | Fortinet
Netronline Taxes
Printable Whoville Houses Clipart
Koopa Wrapper 1 Point 0
Lakers Game Summary
Blackstone Launchpad Ucf
Shaniki Hernandez Cam
Globe Position Fault Litter Robot
Gina's Pizza Port Charlotte Fl
C Spire Express Pay
Craigslist Cars Nwi
Lenscrafters Huebner Oaks
TS-Optics ToupTek Color Astro Camera 2600CP Sony IMX571 Sensor D=28.3 mm-TS2600CP
Fear And Hunger 2 Irrational Obelisk
Dr. med. Uta Krieg-Oehme - Lesen Sie Erfahrungsberichte und vereinbaren Sie einen Termin
List of all the Castle's Secret Stars - Super Mario 64 Guide - IGN
Msu 247 Football
Hobby Stores Near Me Now
Att.com/Myatt.
Ups Print Store Near Me
Pecos Valley Sunland Park Menu
Shreveport City Warrants Lookup
683 Job Calls
Weldmotor Vehicle.com
Inter Miami Vs Fc Dallas Total Sportek
Paris Immobilier - craigslist
4 Methods to Fix “Vortex Mods Cannot Be Deployed” Issue - MiniTool Partition Wizard
Shelby Star Jail Log
Democrat And Chronicle Obituaries For This Week
Wolfwalkers 123Movies
Kaliii - Area Codes Lyrics
Plasma Donation Racine Wi
Issue Monday, September 23, 2024
Vip Lounge Odu
Scioto Post News
Greencastle Railcam
Sinai Sdn 2023
Page 5662 – Christianity Today
Rochester Ny Missed Connections
The Closest Walmart From My Location
968 woorden beginnen met kruis
Dickdrainersx Jessica Marie
Toomics - Die unendliche Welt der Comics online
Borat: An Iconic Character Who Became More than Just a Film
Sinai Sdn 2023
Sapphire Pine Grove
Erespassrider Ual
Richard Mccroskey Crime Scene Photos
Pelican Denville Nj
Vcuapi
Latest Posts
Article information

Author: Duane Harber

Last Updated:

Views: 6143

Rating: 4 / 5 (71 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.