Compress Word File with Python REST API

This article describes how to compress Word file with Python REST API. You will learn to compress a picture in Word with Python Low Code API using the Python cloud SDK. It has various options to customize the compression process and generate the output file according to the requirements.

Prerequisite

Steps to Compress a Word DOC with Python Low Code API

  1. Create an object of the WordsApi class with the client ID and the secret to compress a file
  2. Create the CompressDocumentOnlineRequest object and set the CompressOptions, source document and output file
  3. Invoke the CompressDocumentOnline method to compress the pictures in the Word file
  4. Download the compressed output file

The above steps describe how to compress a Word document online with Python REST API. Load the source Word file having images in it and create a CompressDocumentOnlineRequest object by providing the input and output files along with the compression options. Call the CompressDocumentOnline method to compress the Word file and save the output Word file from the API response object.

Code to Compress Word Document with Python REST API

This code demonstrates the process to reduce the size of a Word file with Python Low Code API. The CompressOptions contains the options to set the image quality and factor to reduce the image size. You can also set the load encoding and the password using the CompressDocumentOnlineRequest object.

In this topic, we have learned to compress the Word file size by reducing the image size in a Word file. If you want to change the properties of a Word file, refer to the following article: Change Properties of Word Document with Python REST API.

 English