博文

目前显示的是 四月, 2026的博文

Convert Images to a PDF Using Python (Including Merging)

In everyday office or document work, we often need to merge multiple images into a single PDF file. Whether organizing scans, creating an e-book, or archiving materials, converting images to PDF is a very practical task. This article shows how to use Python and the Spire.PDF for Python library to easily convert and merge images into a PDF. Why Use Spire.PDF for Python? Spire.PDF for Python is a powerful PDF manipulation library that not only supports creating, reading, and editing PDF documents but also provides rich image-handling features. Compared with other libraries, Spire.PDF’s API is simple and intuitive, enabling easy image-to-PDF conversion and allowing precise control of page size and image layout. Install it via PyPI: pip install spire.pdf Complete Code Example The following code demonstrates how to merge all JPG/JPEG images in a specified folder into a single PDF file: from spire.pdf import * import os # Folder path containing images image_folder = r"C:\Users\Admi...