This gist explains the steps and code snippet for the conversion of HTMLfiles to PDF format using Aspose.PDF Cloud SDK for Python.
For more information, please visit
This gist explains the steps and code snippet for the conversion of HTMLfiles to PDF format using Aspose.PDF Cloud SDK for Python.
For more information, please visit
This Gist contains code snippets regarding the conversion of HTML files to PDF format using Aspose.PDF Cloud SDK for Python |
def html2pdf(): | |
try: | |
#initialize PdfApi client instance using ClientID and ClientSecret | |
pdf_api_client = asposepdfcloud.api_client.ApiClient("406b404b2df649611e508bbcfcd2a77f", "88d1cda8-b12c-4a80-b1ad-c85ac483c5c5") | |
# create PdfApi instance while passing PdfApiClient as argument | |
pdf_api = PdfApi(pdf_api_client) | |
# Input HTML file | |
input_file_name = 'source.zip' | |
# name of resultant PDF file | |
resultant_file_name = 'Converted.pdf' | |
# Call API to convert HTML to PDF format | |
# the source HTML is in .zip format along with .css and related images | |
response = pdf_api.put_html_in_storage_to_pdf(src_path='source.zip', html_file_name='completeWorkbook.html', name=resultant_file_name, height='1024', width='800', is_landscape='false') | |
# print message in console (optional) | |
print('HTML successfully converted to PDF format !') | |
except ApiException as e: | |
print("Exception while calling PdfApi: {0}".format(e)) |
def web2pdf(): | |
try: | |
#initialize PdfApi client instance using ClientID and ClientSecret | |
pdf_api_client = asposepdfcloud.api_client.ApiClient("406b404b2df649611e508bbcfcd2a77f", "88d1cda8-b12c-4a80-b1ad-c85ac483c5c5") | |
# create PdfApi instance while passing PdfApiClient as argument | |
pdf_api = PdfApi(pdf_api_client) | |
# Resultant PDF file | |
resultant_file_name = 'Web2PDF.pdf' | |
# Call API to convert webpage/URL to PDF | |
# we have set isLandscape true for better accommodation of webpage contents | |
response = pdf_api.put_web_in_storage_to_pdf(name=resultant_file_name, url='https://www.aspose.cloud/', is_landscape='true') | |
# print message in console (optional) | |
print('Webpage successfully converted to PDF format !') | |
except ApiException as e: | |
print("Exception while calling PdfApi: {0}".format(e)) |