Skip to content

Instantly share code, notes, and snippets.

@blog-aspose-cloud
Last active May 30, 2022 04:29
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/78cbb8a7483ad8f40670f4d738d9f984 to your computer and use it in GitHub Desktop.
Save blog-aspose-cloud/78cbb8a7483ad8f40670f4d738d9f984 to your computer and use it in GitHub Desktop.
This Gist explains the details on for converting Word to TIFF document using Aspose.Words Cloud SDK for Python

Convert Word to TIFF Document in Python


The Gist shares details on how to convert Word to TIFF Document using Aspose.Words Cloud SDK for Python.

In following code snippet, we need to first upload the Word document to cloud storage and then call the SaveAsTiff method to convert Word to TIFF format. The resultant TIFF is saved in cloud storage. For complete details, please visit Convert Word to TIFF Document in Python | DOC to TIFF Online.

Online Word to TIFF Converter

Important Links

Home | Product Page | Docs | API Reference | Cloud Dashboard | Code Samples | Source Code | Blog | Free Support | Free Trial

def wordtotiff():
try:
# create an instance of WordsApi
words_api = WordsApi("bbf94a2c-6d7e-4020-b4d2-b9809741374e","1c9379bb7d701c26cc87e741a29987bb")
# Name of input word document
inputFileName = 'test_multi_pages.docx'
resultantFile = 'resultant.tiff'
# Upload source Word document to Cloud Storage
words_api.upload_file(asposewordscloud.models.requests.UploadFileRequest(open('C:\\Users\\'+inputFileName, 'rb'), "", None))
# Create Document Conversion request
request = asposewordscloud.models.requests.GetDocumentWithFormatRequest(inputFileName, "TIFF", None, None, None,
None, resultantFile, None)
# initiate Word to TIFF conversion operation
result = words_api.get_document_with_format(request)
# print message in console (optional)
print('Conversion process completed successfully !')
except Api as e:
print("Exception while Converting Word to TIFF Document using Aspose.Words Cloud Api: {0}".format(e))
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-python
// Get client credentials from https://dashboard.aspose.cloud/
def wordtotiff():
try:
# create an instance of WordsApi
words_api = WordsApi("bbf94a2c-6d7e-4020-b4d2-b9809741374e","1c9379bb7d701c26cc87e741a29987bb")
# Name of input word document
inputFileName = 'test_multi_pages.docx'
resultantFile = 'resultant.tiff'
# Read the content of word file from local drive
request_document = open('C:\\Users\\'+inputFileName, 'rb')
# Create an object for Document conversion
request = asposewordscloud.models.requests.ConvertDocumentRequest(document=request_document, format="TIFF",out_path=resultantFile)
# initiate Word to TIFF conversion operation
result = words_api.convert_document(request)
# print message in console (optional)
print('Conversion process completed successfully !')
except Api as e:
print("Exception while Converting Word to TIFF Document using Aspose.Words Cloud Api: {0}".format(e))
This Gist explains the details on for converting Word to TIFF document using Aspose.Words Cloud SDK for Python
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-python
// Get client credentials from https://dashboard.aspose.cloud/
def wordtotiff():
try:
# create an instance of WordsApi
words_api = WordsApi("bbf94a2c-6d7e-4020-b4d2-b9809741374e","1c9379bb7d701c26cc87e741a29987bb")
# Name of input word document
inputFileName = 'test_multi_pages.docx'
# Upload source Word document to Cloud Storage
words_api.upload_file(asposewordscloud.models.requests.UploadFileRequest(open('C:\\Users\\shahbnay\\Downloads\\'+inputFileName, 'rb'), "", None))
# Create an object for Document conversion
# request = asposewordscloud.models.requests.GetDocumentWithFormatRequest(inputFileName, "TIFF", None, None, None,
# None, resultantFile, None)
#request_save_options = asposewordscloud.TiffSaveOptionsData(file_name=inputFileName)
request_save_options = {"FileName":inputFileName,
"SaveFormat":"tiff",
"AllowEmbeddingPostScriptFonts":True,
"DmlRenderingMode":"Fallback",
"DmlEffectsRenderingMode":"Simplified",
"ImlRenderingMode": "Fallback",
"ZipOutput": False,
"UpdateLastSavedTimeProperty": True,
"UpdateSdtContent": True,
"UpdateFields": True,
"Dml3DEffectsRenderingMode": "Basic",
"UpdateCreatedTimeProperty": True,
"UpdateLastPrintedProperty": True,
"FlatOpcXmlMappingOnly": True,
"ColorMode": "Normal",
"JpegQuality": 100,
"MetafileRenderingOptions": {
"EmfPlusDualRenderingMode": "EmfPlusWithFallback",
"EmulateRasterOperations": True,
"RenderingMode": "VectorWithFallback",
"UseEmfEmbeddedToWmf": True,
"ScaleWmfFontsToMetafileSize": True
},
"NumeralFormat": "European",
"OptimizeOutput": True,
"PageCount": 1,
"PageIndex": 1,
"HorizontalResolution": 800,
"ImageBrightness": 0,
"ImageColorMode": "None",
"ImageContrast": 0,
"PixelFormat": "Format16BppRgb555",
"Resolution": 800,
"Scale": 1.0,
"UseAntiAliasing": True,
"UseGdiEmfRenderer": True,
"UseHighQualityRendering": True,
"VerticalResolution": 400,
"ThresholdForFloydSteinbergDithering": 0,
"TiffBinarizationMethod": "Threshold",
"TiffCompression": "None"
}
# initiate Word to JPEG conversion operation
#result = words_api.get_document_with_format(request)
result = words_api.save_as_tiff(name=inputFileName,save_options=request_save_options)
# print message in console (optional)
print('Conversion process completed successfully !')
except Api as e:
print("Exception while Converting Word to TIFF Document using Aspose.Words Cloud Api: {0}".format(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment