Please follow the steps given below to read PDF viewer preferences of PDF file using Aspose.PDF Cloud SDK for Python.
For more information, please visit the following blog Control PDF Display Properties using Python.
Please follow the steps given below to read PDF viewer preferences of PDF file using Aspose.PDF Cloud SDK for Python.
For more information, please visit the following blog Control PDF Display Properties using Python.
This Gist contains code snippets on how to retrieve and set PDF viewer preferences using Aspose.PDF Cloud SDK for Python |
def readPDFDisplayProperties(): | |
try: | |
#Client credentials | |
client_secret = "1c9379bb7d701c26cc87e741a29987bb" | |
client_id = "bbf94a2c-6d7e-4020-b4d2-b9809741374e" | |
#initialize PdfApi client instance using client credetials | |
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) | |
#source PDF file | |
input_file = 'PdfWithEmbeddedFiles.pdf' | |
# call API to read PDF display properties using Python | |
response = pdf_api.get_document_display_properties(name = input_file) | |
# print response in console | |
print(response) | |
# print message in console (optional) | |
print('PDF Display preferences successfully retrieved !') | |
except ApiException as e: | |
print("Exception while calling PdfApi: {0}".format(e)) | |
print("Code:" + str(e.code)) | |
print("Message:" + e.message) |
def updatePDFDisplayProperties(): | |
try: | |
#Client credentials | |
client_secret = "1c9379bb7d701c26cc87e741a29987bb" | |
client_id = "bbf94a2c-6d7e-4020-b4d2-b9809741374e" | |
#initialize PdfApi client instance using client credetials | |
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) | |
#source PDF file | |
input_file = 'PdfWithEmbeddedFiles.pdf' | |
# Document display properties | |
newDocumentProperties = asposepdfcloud.DocumentProperties | |
{ | |
"Links": [ | |
{ | |
"Href": '/PdfWithEmbeddedFiles.pdf/displayproperties', | |
"Rel": 'self', | |
"Type": None, | |
"Title": None } | |
], | |
"CenterWindow": True, | |
"Direction": 'L2R', | |
"DisplayDocTitle": True, | |
"HideMenuBar": True, | |
"HideToolBar": False, | |
"HideWindowUI": True, | |
"NonFullScreenPageMode": 'UseOutlines', | |
"PageLayout":'TwoColumnRight', | |
"PageMode": 'UseThumbs' | |
} | |
# call API to udpate PDF display properties | |
response = pdf_api.put_document_display_properties(name = input_file, display_properties=newDocumentProperties) | |
# print response in console | |
print(response) | |
# print message in console (optional) | |
print('PDF Display preferences successfully updated !') | |
except ApiException as e: | |
print("Exception while calling PdfApi: {0}".format(e)) | |
print("Code:" + str(e.code)) | |
print("Message:" + e.message) |