Skip to content

Instantly share code, notes, and snippets.

@blog-aspose-cloud
Last active April 13, 2023 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blog-aspose-cloud/daa2e380647a7e75d7a7e0808d792d73 to your computer and use it in GitHub Desktop.
Save blog-aspose-cloud/daa2e380647a7e75d7a7e0808d792d73 to your computer and use it in GitHub Desktop.
This Gist contains code snippets for converting PDF to TIFF using Aspose.PDF Cloud SDK for Python
This Gist contains code snippets for converting PDF to TIFF using Aspose.PDF Cloud SDK for Python
def PDFtoTIFF():
try:
#Client credentials
client_secret = "1c9379bb7d701c26cc87e741a29987bb"
client_id = "bbf94a2c-6d7e-4020-b4d2-b9809741374e"
#initialize PdfApi client instance using client credentials
pdf_api_client = asposepdfcloud.api_client.ApiClient(client_secret, client_id)
# create PdfApi instance while passing PdfApiClient as argument
pdf_api = PdfApi(pdf_api_client)
# input PDF file
input_file = 'marketing.pdf'
output_file = 'resultant.tiff'
# brightness value for TIFF
brightness = 100
# Specify compression for resultant file
compressionFactor = 'LZW'
# color depth details
colorDepth = 'Format8bpp'
# margin details for resultant TIFF
leftMargin = rightMargin = topMargin = bottomMargin = 2
# Orientation of resultant Image
orientation = None
# specify to skip blank pages during conversion
skipBlankPages = True
# width of resultant TIFF
width = 2000
# height of resultant TIFF
height = 1800
#resolution of resultant TIFF file
xResolution = 100
yResolution = 100
# Set the start page for export operation
startPageIndex = 1
# Set the count for pages to be exported
pageCount = 1
# call the API to convert PDF to TIFF and save resultant to Cloud storage
response = pdf_api.put_pdf_in_storage_to_tiff(name = input_file, out_path= output_file, brightness = brightness,
compression = compressionFactor,color_depth = colorDepth, left_margin = leftMargin,
right_margin = rightMargin, top_margin = topMargin, bottom_margin=bottomMargin,
orientation=orientation, skip_blank_pages = skipBlankPages,
width = width, height = height, x_resolution = xResolution,
y_resolution=yResolution, page_index = startPageIndex, page_count = pageCount)
print(response)
# print message in console (optional)
print('PDF successfully converted to TIFF format !')
except ApiException as e:
print("Exception while calling PdfApi: {0}".format(e))
print("Code:" + str(e.code))
print("Message:" + e.message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment