Skip to content

Instantly share code, notes, and snippets.

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/9ab6608c8f8987a56acb8dd02767fb14 to your computer and use it in GitHub Desktop.
Save blog-aspose-cloud/9ab6608c8f8987a56acb8dd02767fb14 to your computer and use it in GitHub Desktop.
This Gist contains code snippets on how to Import XML / FDF / XFDF data to PDF form using Aspose.PDF Cloud SDK for Python
This Gist contains code snippets on how to Import XML / FDF / XFDF data to PDF form using Aspose.PDF Cloud SDK for Python
def importFDFData():
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 form
input_file = 'FormData.pdf'
# source FDF with data
inputFDF = 'importData.fdf'
# call the API to import FDF data in PDF form
response = pdf_api.put_import_fields_from_fdf_in_storage(name = input_file, xml_file_path = inputFDF)
# print response in console
print(response)
# print message in console (optional)
print('FDF data successfully Imported to PDF Form !')
except ApiException as e:
print("Exception while calling PdfApi: {0}".format(e))
print("Code:" + str(e.code))
print("Message:" + e.message)
def importXFDFdata():
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 = 'FormData.pdf'
# input XFDF file
inputXFDF = 'exportedData.xfdf'
# call API to import XFDF data to PDF form
response = pdf_api.put_import_fields_from_xfdf_in_storage(name = input_file, xfdf_file_path = inputXFDF)
# print response code in console
print(response)
# print message in console (optional)
print('XFDF Data successfully Imported to PDF Form !')
except ApiException as e:
print("Exception while calling PdfApi: {0}".format(e))
print("Code:" + str(e.code))
print("Message:" + e.message)
def importXMLData():
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 form
input_file = 'FormData.pdf'
# source XML with data
inputXML = 'importData.xml'
# call the API to import XML data in PDF form
response = pdf_api.put_import_fields_from_xml_in_storage(name = input_file, xml_file_path = inputXML)
# print response in console
print(response)
# print message in console (optional)
print('XML Data successfully Imported to PDF Form !')
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