Skip to main content

Posts

Compress PDF Files with Python: Images, Fonts & Document Content

  Large PDF files are not always caused by a high page count. High-resolution images, scanned pages, embedded fonts, and insufficiently compressed document content can all increase file size significantly. When PDFs need to be sent by email, uploaded to a website, or stored in bulk, the best compression method depends on what the file contains. For example, scanned PDFs usually benefit most from image compression, while text-heavy documents may be reduced by compressing fonts and document content. This article shows how to compress images, fonts, and document content in PDF files with Python, as well as how to process multiple PDFs in a folder. Environment Setup To run the code examples below, first install the required Python module for PDF processing: pip install Spire.PDF Compress Images in a PDF with Python For scanned documents, product manuals, screenshots, and similar PDFs, images often account for most of the file size. You can reduce the size of these files by compressing ...

How to Convert XLS to XLSX and XLSX to XLS Using Python

  Excel files can be saved in different formats depending on the version of Microsoft Excel and the application that generates them. Among these formats, .xls and .xlsx are the two most commonly used. The .xls format was used by older versions of Excel, while .xlsx became the default format after Excel 2007. Although .xlsx is now widely used, .xls files can still be found in many existing systems and applications. When working with Excel files in Python, converting between these two formats is sometimes necessary, especially when dealing with legacy files or applications with specific format requirements. This article shows how to convert .xls files to .xlsx and .xlsx files to .xls using Python. Why Convert between XLS and XLSX? The .xlsx format provides several improvements over the older .xls format: Higher capacity : .xlsx supports more rows and columns than .xls . Better compatibility : It works better with newer versions of Excel and other spreadsheet applicatio...