adobe.pdfservices.operation.pdfjobs.jobs.export\_pdf\_form\_data package

Submodules

adobe.pdfservices.operation.pdfjobs.jobs.export\_pdf\_form\_data.export\_pdf\_form\_data\_job module

class adobe.pdfservices.operation.pdfjobs.jobs.export_pdf_form_data_job.ExportPDFFormDataJob(input_asset: Asset, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that exports form data from a PDF and retrieves it in JSON format.

This job demonstrates how to use Adobe PDF Services SDK to extract form data from a PDF file. The process involves uploading a source PDF, submitting an export form data job, and retrieving the extracted data.

Sample usage:

file = open('SOURCE_PATH', 'rb')
input_stream = file.read()
file.close()

credentials = ServicePrincipalCredentials(
    client_id=os.getenv('PDF_SERVICES_CLIENT_ID'),
    client_secret=os.getenv('PDF_SERVICES_CLIENT_SECRET')
)

pdf_services = PDFServices(credentials=credentials)
input_asset = pdf_services.upload(input_stream=input_stream, mime_type=MediaType.PDF)

export_pdf_form_data_job = ExportPDFFormDataJob(input_asset=input_asset)

location = pdf_services.submit(export_pdf_form_data_job)
pdf_services_response = pdf_services.get_job_result(location, ExportPDFFormDataResult)

result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

# Save the form data JSON to a file
output_file_path = "extracted_form_data.json"
with open(output_file_path, 'wb') as output_file:
    output_file.write(stream_asset.get_input_stream())

Constructs a new ExportPDFFormDataJob instance.

Parameters:
  • input_asset (Asset) – Asset object containing the input file; can not be None.

  • output_asset (Asset) – Asset object representing the output asset. (Optional, use key-value)

Returns:

A new instance of ExportPDFFormDataJob.

Return type:

ExportPDFFormDataJob

Note

External assets can be set as output only when input is external asset as well

Module contents