Get PDF Version

Contents
[ ]

PDF versions define the features and capabilities supported in a document, including form fields, encryption, annotations, and compression. For developers working with multiple PDFs, checking the version ensures compatibility with tools, libraries, or workflows that process these files.

Using Aspose.PDF for Python, you can easily inspect the PDF version with the PdfFileInfo class.

  1. Load a PDF document.
  2. Retrieve its PDF version.
  3. Display the version in the console.
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades
from io import FileIO

import sys
from os import path

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


def get_pdf_version(input_file_name):

    pdf_metadata = pdf_facades.PdfFileInfo(input_file_name)
    version = pdf_metadata.get_pdf_version()
    print(f"\nPDF Version: {version}")