How to use the command 'pdfinfo' (with examples)
The pdfinfo
command is a tool used to extract and view metadata and other information about PDF files. It is part of the suite provided by Xpdf, a free PDF viewer for operating systems such as Unix, Linux, and Windows. This command enables users to access details like PDF version, number of pages, title, author, and more. It is especially useful for those working with numerous PDF documents who need to quickly gather pertinent document information without opening each file.
Use case 1: Print PDF file information
Code:
pdfinfo path/to/file.pdf
Motivation:
The most basic and widely used functionality of pdfinfo
is to gather and display all available information about a PDF file. For instance, if you manage a large number of PDF documents and require details about each file, such as page count or modification date, leveraging this command will enable you to acquire that information efficiently without laboriously opening each file individually.
Explanation:
pdfinfo
: This initiates the command used to display information about a PDF file.path/to/file.pdf
: This is the path to the PDF file whose information you wish to retrieve. You can replace ‘path/to/file.pdf’ with the actual path where the PDF is located on your system.
Example output:
Title: Example Document
Author: Jane Doe
Creator: Adobe InDesign 16.0 (Windows)
Producer: Adobe PDF Library 15.0
CreationDate: Tue Oct 5 12:31:00 2021 CEST
ModDate: Thu Oct 7 16:23:11 2021 CEST
Tagged: yes
Form: none
Pages: 42
Encrypted: no
Page size: 595.276 x 841.89 pts (A4)
PDF version: 1.7
This output includes various pieces of metadata, such as the title and author of the document, when it was created and last modified, the number of pages, and more.
Use case 2: Specify user password for PDF file to bypass security restrictions
Code:
pdfinfo -upw password path/to/file.pdf
Motivation:
Many PDF files are protected by security restrictions requiring a user password to access specific features or view the file altogether. By using the -upw
flag, users can supply the necessary password to bypass these restrictions. This is particularly useful for secured reports or e-books that you need to access as part of your workflow.
Explanation:
pdfinfo
: The command being used ispdfinfo
.-upw password
: The-upw
stands for “user password,” indicating the password to access the PDF’s content. Replace ‘password’ with the actual user password required for the PDF.path/to/file.pdf
: Represents the path to the PDF file you’re targeting.
Example output:
Title: Secured Report
Author: John Smith
Creator: PDFWriter 3.0
Producer: PDF Generator Pro
CreationDate: Sat Jan 10 09:15:22 2020 PDT
ModDate: Mon Feb 3 10:17:55 2020 PDT
Tagged: no
Form: AcroForm
Pages: 30
Encrypted: yes (print:yes copy:no change:no addNotes:no)
Page size: 612 x 792 pts (letter)
PDF version: 1.6
When access is granted, all file information, including any security settings, is displayed.
Use case 3: Specify owner password for PDF file to bypass security restrictions
Code:
pdfinfo -opw password path/to/file.pdf
Motivation:
Some PDF files are protected with an owner password, which provides greater control over its usage. This password might allow a user to alter permissions such as printing or editing the document. Using -opw
, pdfinfo
lets users enter the owner password to bypass these restrictions, useful for users who need to modify or print the protected document under legitimate circumstances.
Explanation:
pdfinfo
: This command invokes thepdfinfo
utility.-opw password
: The-opw
flag denotes “owner password,” intended to bypass security settings. Replace ‘password’ with the owner password for the PDF file.path/to/file.pdf
: Path to the specific secured PDF file.
Example output:
Title: Proprietary Analysis
Author: Lisa Brown
Creator: Proprietary Software 2.1
Producer: Proprietary Software 2.1
CreationDate: Wed Mar 11 10:22:31 2018 EST
ModDate: Fri Mar 13 11:23:45 2018 EST
Tagged: no
Form: none
Pages: 55
Encrypted: yes (print:yes copy:yes change:yes addNotes:yes)
Page size: 420 x 595 pts (A5)
PDF version: 1.5
With the owner password, one can see permissions are lifted as detailed in the ‘Encrypted’ field.
Conclusion:
The pdfinfo
command is an insightful utility in managing PDF files, offering users the ability to quickly access document metadata and security information, regardless of password protection. By understanding each use case, users can effectively bypass security constraints (where authorized) to extract necessary details for personal or professional data management tasks.