PDF to Image

Convert PDF to Image | Build PDF to Image converter in Python

PDF is one of the most commonly used file formats for sharing and storing documents. However, there are times when you need to convert your PDF files to different image formats, such as TIFF. TIFF is a widely used image format that is known for its high-quality images and compatibility with various applications. There are several reasons why you might need to convert a PDF file to a TIFF image, such as preserving document quality, archiving, or improving document processing efficiency. In this article, we will explore how to perform PDF to TIFF conversion using Python Cloud SDK.

We are preferring TIFF because it is lossless, i.e. you do not lose the quality after saving and editing the file, no matter how many times you do it.

PDF Conversion API

Aspose.PDF Cloud is a REST-based API that allows developers to create, edit and convert PDF documents in the cloud. It provides various features for PDF conversion, including the ability to convert PDF to TIFF. Furthermore, you can use Aspose.PDF Cloud SDK for Python to interact with this API and perform the conversion. The SDK offers a simple and intuitive interface that makes it easy to integrate Aspose.PDF Cloud into your Python applications.

Download and install the SDK from the PIP repository by executing the following command in the terminal/command prompt.

pip install asposepdfcloud

Secondly, you need to create a free subscription account over Cloud dashboard. If you have a GitHub or Google account, simply Sign Up or, click on the Create a new Account button and obtain client credentials.

Convert PDF to TIFF using Python

When converting PDF to TIFF format, we get the option to specify TIFF compression values such as LZW, CCITT4, CCITT3, RLE, and None. Similarly, the API also enables you to control ColorDepth where possible values can be Default, Format8bpp, Format4bpp, or Format1bpp. We may also set the orientation of the resultant image as None, Landscape and Portrait. Now in order to convert PDF to TIFF, following API methods are available and, we can select either of them (as per requirement).

In the following section, we are going to load a PDF file from cloud storage and convert it to a TIFF image. After the conversion, the resultant file is stored in the cloud storage (2nd option as specified above)

  • Firstly, we need to create an instance of ApiClient class that requires Client ID Client Secret as arguments.
  • Secondly, create an instance of PdfApi class that requires the ApiClient object as an input argument.
  • Thirdly, create variables defining input PDF and resultant TIFF names.
  • Set the resolution, compression factor, color depth, margin, orientation, dimensions, and resolution details.
  • Finally, call put_pdf_in_storage_to_tiff(…) method to initiate the conversion operation.
PDF to Image

Image2:- PDF to TIFF conversion preview.

For your reference, we have also uploaded the input marketing.pdf and resultant.tiff, used in the above example.

PDF to TIFF using cURL Command

Aspose.PDF Cloud API provides a powerful set of APIs to work with PDF files in the cloud, allowing you to easily convert PDF documents to TIFF images. Also, the cURL command-line tool is a popular and powerful tool that can be used to interact with web services, making it a great choice for working with cloud-based APIs like Aspose.PDF Cloud. Using cURL commands to convert PDF to TIFF offers several benefits, including the ability to automate the conversion process, integrate with other command-line tools, and easily script complex workflows. Additionally, since the conversion is performed in the cloud, you can take advantage of the scalability and reliability of cloud computing, without the need to install and maintain any local software.

Now, first we need to generate a JSON Web Token (JWT) based on the client credentials. So, please execute the following command to generate the JWT token.

curl -v "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=88d1cda8-b12c-4a80-b1ad-c85ac483c5c5&client_secret=406b404b2df649611e508bbcfcd2a77f" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once the JWT Token has been generated, please execute the following command to render the PDF document to a TIFF image and save the resultant output Cloud storage.

curl -X PUT "https://api.aspose.cloud/v3.0/pdf/marketing.pdf/convert/tiff?outPath=Resultant.tiff&brightness=100&compression=LZW&colorDepth=Format8bpp&leftMargin=10&rightMargin=10&topMargin=10&bottomMargin=10&orientation=None&skipBlankPages=true&width=1024&height=800&xResolution=300&yResolution=300&pageIndex=1&pageCount=1" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \

Concluding Remarks

In conclusion, converting PDF to TIFF is a crucial task for many industries that deal with documents. The process can be easily achieved using Python and the Aspose.PDF Cloud SDK, which offers a variety of options for customizing the output TIFF file, such as DPI, compression, and color depth. Additionally, the conversion can also be performed using cURL commands, making it accessible for developers who prefer to use command-line tools. No matter the method used, converting PDF to TIFF can improve the accessibility and portability of documents, making them easier to share and manage across different platforms and devices.

We recommend visiting the following articles to learn about: