Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert Word to TIFF File in Python
# API initialization to download converted file
import shutil
file_api = groupdocs_conversion_cloud.FileApi.from_config(configuration)
# Create download file request
request = groupdocs_conversion_cloud.DownloadFileRequest("python-testing\\sample-word.tiff", storage_name)
# Download converted file
response = file_api.download_file(request)
# Move the downloaded tiff image file to your local directory
shutil.move(response, "H:\\groupdocs-cloud-data\\")
# Upload word file to cloud storage
# Create an instance of the file API
file_api = groupdocs_conversion_cloud.FileApi.from_config(configuration)
# Call upload file request
request = groupdocs_conversion_cloud.UploadFileRequest("python-testing\sample-word.docx", "H:\\groupdocs-cloud-data\\word-file.docx", storage_name)
# Upload docx file to the cloud
response = file_api.upload_file(request)
print(response.uploaded)
# This code example demonstrates how to convert word pages to TIFF format in Python
try:
# Create an instance of the API
convert_api = groupdocs_conversion_cloud.ConvertApi.from_keys(client_id, client_secret)
# Define convert settings
settings = groupdocs_conversion_cloud.ConvertSettings()
settings.storage_name = storage_name
settings.file_path = "python-testing/sample-word.docx"
settings.format = "tiff"
loadOptions = groupdocs_conversion_cloud.DocxLoadOptions()
loadOptions.password = "password"
settings.load_options = loadOptions
convertOptions = groupdocs_conversion_cloud.TiffConvertOptions()
convertOptions.gray_scale = True
convertOptions.from_page = 1
convertOptions.pages_count = 1
convertOptions.quality = 100
convertOptions.rotate_angle = 90
convertOptions.use_pdf = False
settings.convert_options = convertOptions
settings.output_path = "python-testing"
request = groupdocs_conversion_cloud.ConvertDocumentRequest(settings)
response = convert_api.convert_document(request)
print("Successfully converted Word to Tiff image format: " + str(response))
except groupdocs_conversion_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))

You can convert Word DOCX to TIFF format programmatically on the cloud. In this article, you will learn how to convert Word to TIFF File in Python using REST API.

The following topics are covered in this article:

  1. Python Word to TIFF Converter API – Installation
  2. How to Convert Word DOCX to TIFF Format in Python
  3. Convert Range of Pages from Word to TIFF File in Python
  4. Convert Specific Pages of Word to TIFF Image in Python
# How to Convert Word DOCX to TIFF Format in Python
try:
# Create an instance of the API
convert_api = groupdocs_conversion_cloud.ConvertApi.from_keys(client_id, client_secret)
# Define convert settings
settings = groupdocs_conversion_cloud.ConvertSettings()
settings.storage_name = storage_name
settings.file_path = "python-testing/sample-word.docx"
settings.format = "tiff"
loadOptions = groupdocs_conversion_cloud.DocxLoadOptions()
loadOptions.password = "password"
settings.load_options = loadOptions
settings.output_path = "python-testing"
request = groupdocs_conversion_cloud.ConvertDocumentRequest(settings)
response = convert_api.convert_document(request)
print("Successfully converted Word to Tiff image format: " + str(response))
except groupdocs_conversion_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# This code example demonstrates how to convert specific pages of word to TIFF
try:
# Create an instance of the API
convert_api = groupdocs_conversion_cloud.ConvertApi.from_keys(client_id, client_secret)
# Define convert settings
settings = groupdocs_conversion_cloud.ConvertSettings()
settings.storage_name = storage_name
settings.file_path = "python-testing/sample-word.docx"
settings.format = "tiff"
# Set DOCX LoadOptions
loadOptions = groupdocs_conversion_cloud.DocxLoadOptions()
loadOptions.password = "password"
settings.load_options = loadOptions
convertOptions = groupdocs_conversion_cloud.TiffConvertOptions()
# The page indexes of the specific pages to be converted
convertOptions.pages = [2, 3, 4]
convertOptions.gray_scale = True
convertOptions.quality = 100
convertOptions.rotate_angle = 90
convertOptions.use_pdf = False
settings.convert_options = convertOptions
settings.output_path = "python-testing"
request = groupdocs_conversion_cloud.ConvertDocumentRequest(settings)
response = convert_api.convert_document(request)
print("Successfully converted Word to Tiff image format: " + str(response))
except groupdocs_conversion_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import Python SDK in your python application from http://api.groupdocs.cloud
import groupdocs_conversion_cloud
# Get client_id and client_secret from https://dashboard.groupdocs.cloud after free registration.
client_id = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Get File API configurations
configuration = groupdocs_conversion_cloud.Configuration(client_id, client_secret)
configuration.api_base_url = "https://api.groupdocs.cloud"
storage_name = "DefaultStorage"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment