Open In App

How to convert a PDF file to TIFF file using Python?

Last Updated : 30 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

This article will discover how to transform a PDF (Portable Document Format) file on your local drive into a TIFF (Tag Image File Format) file at the specified location. We’ll employ Python’s Aspose-Words package for this task. The aspose-words library will be used to convert a PDF file to a TIFF file.

Aspose-Words: Aspose-Words for Python is a potent on-premise class library that may be used for various document processing applications. Without relying on third-party apps, or automation, it allows developers to extend their own applications with functionality like document generation, modification, conversion, rendering, and printing. Run the subsequent command in the Terminal Window in order to install this module:

pip install aspose-words

What is a TIFF File?

A TIFF file, also known as a Tag Image File Format, is an image format used to store raster graphics and data. Due to their capacity to maintain the original image quality even after being compressed or enlarged numerous times without losing any detail from the original source material, TIFF files are frequently used for high-quality printing purposes such as magazines, newspapers, brochures, posters, and so forth. It is appropriate for usage in print media where colors must be accurately reproduced across various devices like printers and scanners since it supports both the RGB (Red Green Blue) and CMYK (Cyan Magenta Yellow Black) color models.

What is a PDF File?

PDF is an abbreviation for Portable Document Format, which is used to display documents in electronic form regardless of the software, hardware, or operating system on which they are read. No matter what computer, gadget, or piece of software is used to view a PDF, the content and layout always seem exactly the same. You can incorporate many other sorts of material into PDF files, including text, photos, and vector graphics, movies, animations, audio files, 3D models, interactive fields, hyperlinks, and buttons. You can organize all of these components as a report, a presentation, or a portfolio by combining them in a single PDF file. Everyone can easily make, view, and use PDF files.

Example

Import required aspose.words module. Use Try and Except Block to handle Exceptions. Access the PDF using Document( ) function from the module to open the PDF File. Save the TIFF File with the save( ) function from the module to convert the PDF File to TIFF File. Print the statement as “Successfully Converted!” to indicate the task completion in the Terminal Window else print “Couldn’t Convert!” in case of any Exceptions

Python3




# Import the required module
import aspose.words as aw
  
# Use Try and Except Block
try:
  
    # Open the Document
    doc = aw.Document('D:/Blog/GeeksForGeeks.pdf')
  
# Save the Document in the TIFF Format
    doc.save('D:/Blog/GeeksForGeeks.tiff')
  
# Print it is Converted!
    print("Successfully Converted!")
  
except:
  
    # Print Couldn't Convert
    print("Couldn't Convert")
  
# This code is Contributed by PL VISHNUPPRIYAN


Output:

Your input file will have been transformed into a TIFF file and placed in the specified folder, and you can see the following output in the Terminal Window

Output in Terminal Window

File Input:

Input: GeeksForGeeks.pdf File

File Output:

Output: GeeksForGeeks.tiff FIle

Output Generated:

Output: Inside TIFF file


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads