Skip to content

Instantly share code, notes, and snippets.

@blog-aspose-cloud
Last active January 3, 2022 22:11
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/47c0e858a03b543c0380f0f36a2c2047 to your computer and use it in GitHub Desktop.
Save blog-aspose-cloud/47c0e858a03b543c0380f0f36a2c2047 to your computer and use it in GitHub Desktop.
This Gist contains code snippets on how to PDF to XML / FDF / XFDF using Aspose.PDF Cloud SDK for Python
This Gist contains code snippets on how to PDF to XML / FDF / XFDF using Aspose.PDF Cloud SDK for Python
def exportPDFtoFDF():
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-Filled.pdf'
# resultant FDF name
outputFDF = 'exportedData.fdf'
# Export PDF form data to FDF and save output in Cloud storage
response = pdf_api.put_export_fields_from_pdf_to_fdf_in_storage(name = input_file, fdf_output_file_path=outputFDF)
# print response on console
print(response)
# print message in console (optional)
print('PDF Form data successfully exported to FDF !')
except ApiException as e:
print("Exception while calling PdfApi: {0}".format(e))
print("Code:" + str(e.code))
print("Message:" + e.message)
def exportPDFtoXFDF():
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-Filled.pdf'
# resultant XFDF name
outputXFDF = 'exportedData.xfdf'
# Export PDF form data to XFDF and save output in Cloud storage
response = pdf_api.put_export_fields_from_pdf_to_xfdf_in_storage(name = input_file, xml_output_file_path=outputXFDF)
# print response on console
print(response)
# print message in console (optional)
print('PDF Form data successfully exported to XFDF !')
except ApiException as e:
print("Exception while calling PdfApi: {0}".format(e))
print("Code:" + str(e.code))
print("Message:" + e.message)
def exportPDFtoXML():
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-Filled.pdf'
# resultant XML name
outputXML = 'exportedData.xml'
# Export PDF form data to XML and save output in Cloud storage
response = pdf_api.put_export_fields_from_pdf_to_xml_in_storage(name = input_file, xml_output_file_path=outputXML)
# print response on console
print(response)
# print message in console (optional)
print('PDF Form data successfully exported to XML !')
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