Jobs

AutotagPDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.autotag_pdf_job.AutotagPDFJob(input_asset: Asset, *, autotag_pdf_params: AutotagPDFParams | None = None, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that creates PDF documents with enhanced readability from existing PDF documents. An optional tagging report can also be generated which contains the information about the tags that the tagged output PDF document contains.

Accessibility tags, used by assistive technology such as screen reader are required to make PDF files compliant. However, the generated PDF is not guaranteed to comply with accessibility standards such as WCAG and PDF/UA as there could be a need to perform further downstream remediation to meet those standards.

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)
autotag_pdf_job = AutotagPDFJob(input_asset)
location = pdf_services.submit(autotag_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, AutotagPDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_tagged_pdf()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new instance of AutotagPDFJob.

Parameters:
  • input_asset (Asset) – The input asset for the job; can not be None.

  • autotag_pdf_params (AutotagPDFParams) – AutotagPDFParams to set.(Optional, use key-value)

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of AutotagPDFJob

Return type:

AutotagPDFJob

CombinePDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.combine_pdf_job.CombinePDFJob(combine_pdf_params: CombinePDFParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that combines multiple PDF files into a single PDF file. Allows specifying which pages of the source files to combine.

Sample usage.

file = open('SOURCE_PATH_1', 'rb')
input_stream_1 = file.read()
file.close()
file = open('SOURCE_PATH_2', 'rb')
input_stream_2 = 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)
stream_assets = [StreamAsset(input_stream_1, MediaType.PDF),
                 StreamAsset(input_stream_2, MediaType.PDF)]
assets = pdf_services.upload_assets(stream_assets)
combine_pdf_params = ((CombinePDFParams()
                      .add_asset(assets[0]))
                      .add_asset(assets[1]))
combine_pdf_job = CombinePDFJob(combine_pdf_params=combine_pdf_params)
location = pdf_services.submit(combine_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, CombinePDFResult)
result_asset: CombinePDFResult = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new CombinePDFJob instance.

Parameters:
  • combine_pdf_params (CombinePDFParams) – CombinePDFParams to set; can not be None.

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of CombinePDFJob

Return type:

CombinePDFJob

CompressPDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.compress_pdf_job.CompressPDFJob(input_asset: Asset, *, compress_pdf_params: CompressPDFParams | None = None, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that reduces the size of a PDF file. Allows specifying CompressionLevel for compressing pdf

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)
compress_pdf_job = CompressPDFJob(input_asset=input_asset)
location = pdf_services.submit(compress_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, CompressPDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new CompressPDFJob instance.

Parameters:
  • input_asset (Asset) – The input asset for the job; can not be None.

  • compress_pdf_params (CompressPDFParams) – CompressPDFParams to set.(Optional, use key-value)

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of CompressPDFJob

Return type:

CompressPDFJob

CreatePDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.create_pdf_job.CreatePDFJob(input_asset: Asset, *, create_pdf_params: CreatePDFParams | None = None, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that converts a non-PDF file to a PDF file. Some source formats may have associated conversion parameters.

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.DOCX)
create_pdf_job = CreatePDFJob(input_asset)
location = pdf_services.submit(create_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, CreatePDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new instance of CreatePDFJob.

Parameters:
  • input_asset (Asset) – The input asset for the job; can not be None.

  • create_pdf_params (CreatePDFParams) – CreatePDFParams to set.(Optional, use key-value)

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of CreatePDFJob.

Return type:

CreatePDFJob

DeletePagesJob

class adobe.pdfservices.operation.pdfjobs.jobs.delete_pages_job.DeletePagesJob(input_asset: Asset, delete_pages_params: DeletePagesParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job to delete pages in a PDF file.

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)
page_ranges_for_deletion = PageRanges()
page_ranges.add_single_page(1)
delete_pages_params = DeletePagesParams(page_ranges=page_ranges_for_deletion)
delete_pages_job = DeletePagesJob(input_asset=input_asset,
                                  delete_pages_params=delete_pages_params)
location = pdf_services.submit(delete_pages_job)
pdf_services_response = pdf_services.get_job_result(location, CompressPDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new DeletePagesJob instance.

Parameters:
  • input_asset (Asset) – The input asset for the job; can not be None.

  • delete_pages_params (DeletePagesParams) – DeletePagesParams to set.(Optional, use key-value)

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of DeletePagesJob

Return type:

DeletePagesJob

DocumentMergeJob

class adobe.pdfservices.operation.pdfjobs.jobs.document_merge_job.DocumentMergeJob(input_asset: Asset, document_merge_params: DocumentMergeParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that enables the clients to produce high fidelity PDF and Word documents with dynamic data inputs. This operation merges the JSON data with the Word template to create dynamic documents for contracts and agreements, invoices, proposals, reports, forms, branded marketing documents and more.

To know more about document generation and document templates, Click Here.

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.DOCX)
json_data_for_merge = {"customerName": "Kane Miller", "customerVisits": 100}
document_merge_params = DocumentMergeParams(json_data_for_merge=json_data_for_merge,
                                            output_format=OutputFormat.DOCX)
document_merge_job = DocumentMergeJob(input_asset=input_asset,
                                      document_merge_params=document_merge_params)
location = pdf_services.submit(document_merge_job)
pdf_services_response = pdf_services.get_job_result(location, DocumentMergePDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new DocumentMergeJob instance.

Parameters:
  • input_asset (Asset) – The input asset for the job; can not be None.

  • document_merge_params (DocumentMergeParams) – DocumentMergeParams to set. can not be None.

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of DocumentMergeJob

Return type:

DocumentMergeJob

PDFElectronicSealJob

class adobe.pdfservices.operation.pdfjobs.jobs.eseal_job.PDFElectronicSealJob(input_asset: Asset, electronic_seal_params: PDFElectronicSealParams, *, seal_image_asset: Asset | None = None, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that allows clients to apply an electronic seal onto various PDF documents such as agreements, invoices, and more.

To know more about PDF Electronic Seal, Click Here.

Sample usage.

pdf_file = open('SOURCE_PATH', 'rb')
file_input_stream = pdf_file.read()
pdf_file.close()

seal_image_file = open('IMAGE_SOURCE_PATH', 'rb')
seal_image_input_stream = seal_image_file.read()
seal_image_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)
asset = pdf_services.upload(input_stream=file_input_stream, mime_type=PDFServicesMediaType.PDF)
seal_image_asset = pdf_services.upload(input_stream=seal_image_input_stream, mime_type=PDFServicesMediaType.PNG)
document_level_permission = DocumentLevelPermission.FORM_FILLING
seal_field_name = "Signature1"
seal_page_number = 1
seal_visible = True
field_location = FieldLocation(150, 250, 350, 200)
field_options = FieldOptions(
    field_name=seal_field_name,
    field_location=field_location,
    page_number=seal_page_number,
    visible=seal_visible
)
provider_name = "<PROVIDER_NAME>"
access_token = "<ACCESS_TOKEN>"
credential_id = "<CREDENTIAL_ID>"
pin = "<PIN>"
csc_auth_context = CSCAuthContext(
    access_token=access_token,
    token_type="Bearer",
)
certificate_credentials = CSCCredentials(
    provider_name=provider_name,
    credential_id=credential_id,
    pin=pin,
    csc_auth_context=csc_auth_context,
)
electronic_seal_params = PDFElectronicSealParams(
    seal_certificate_credentials=certificate_credentials,
    seal_field_options=field_options,
)
electronic_seal_job = PDFElectronicSealJob(input_asset=asset,
                                           electronic_seal_params=electronic_seal_params,
                                           seal_image_asset=seal_image_asset)
location = pdf_services.submit(electronic_seal_job)
pdf_services_response = pdf_services.get_job_result(location, ESealPDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new PDFElectronicSealJob instance.

Parameters:
  • input_asset (Asset) – The input asset for the job; can not be None.

  • electronic_seal_params (PDFElectronicSealParams) – Parameters for electronic seal; can not be None.

  • seal_image_asset (Asset) – Seal image asset for the job. (Optional, use key-value)

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of PDFElectronicSealJob.

Return type:

PDFElectronicSealJob

ExportPDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.export_pdf_job.ExportPDFJob(input_asset: Asset, export_pdf_params: ExportPDFParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job which exports a source PDF file to a supported format specified by ExportPDFTargetFormat

For example, a PDF can be exported to a DOCX file as follows:

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_params = ExportPDFParams(target_format=ExportPDFTargetFormat.DOCX)
export_pdf_job = ExportPDFJob(input_asset=input_asset, export_pdf_params=export_pdf_params)
location = pdf_services.submit(export_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, ExportPDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new ExportPDFJob instance.

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

  • export_pdf_params (ExportPDFParams) – ExportPDFParams object containing the export parameters; can not be None.

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

Returns:

A new instance of ExportPDFJob.

Return type:

ExportPDFJob

Note

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

ExportPDFtoImagesJob

class adobe.pdfservices.operation.pdfjobs.jobs.export_pdf_to_images_job.ExportPDFtoImagesJob(input_asset: Asset, export_pdf_to_images_params: ExportPDFtoImagesParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job which exports a source PDF file to a supported format specified by ExportPDFToImagesTargetFormat

The result is a list of images or a list containing a zip of images. For example, a PDF file with 15 pages will generate 15 image files. The first file’s name ends with “_0” and the last file’s name ends with “_14”.

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_to_images_params = ExportPDFtoImagesParams(
    export_pdf_to_images_target_format=ExportPDFToImagesTargetFormat.JPEG,
    export_pdf_to_images_output_type=ExportPDFToImagesOutputType.LIST_OF_PAGE_IMAGES
)
export_pdf_to_images_job = ExportPDFtoImagesJob(
    input_asset=input_asset,
    export_pdf_to_images_params=export_pdf_to_images_params
)
location = pdf_services.submit(export_pdf_to_images_job)
pdf_services_response = pdf_services.get_job_result(location, ExportPDFtoImagesResult)
result_assets = pdf_services_response.get_result().get_assets()

Constructs a new ExportPDFToImagesJob instance.

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

  • export_pdf_to_images_params (ExportPDFtoImagesParams) – ExportPDFToImagesParams object containing the export to images parameters; can not be None.

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

ExtractPDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.extract_pdf_job.ExtractPDFJob(input_asset: Asset, *, extract_pdf_params: ExtractPDFParams | None = None, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that extracts pdf elements such as text, images, tables in a structured format from a PDF.

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)
extract_pdf_params = ExtractPDFParams(
    elements_to_extract=[ExtractElementType.TEXT],
)
extract_pdf_job = ExtractPDFJob(input_asset=input_asset, extract_pdf_params=extract_pdf_params)

# Submit the job and gets the job result
location = pdf_services.submit(extract_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, ExtractPDFResult)

# Get content from the resulting asset(s)
result_asset: CloudAsset = pdf_services_response.get_result().get_resource()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new ExtractPDFJob instance.

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

  • extract_pdf_params (ExtractPDFParams) – ExtractPDFParams object containing the extract PDF parameters, (Optional, use key-value)

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

HTMLtoPDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.html_to_pdf_job.HTMLtoPDFJob(*, input_asset: Asset | None = None, input_url: str | None = None, html_to_pdf_params: HTMLtoPDFParams | None = None, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that converts a HTML file to a PDF file.

An HTML input can be provided either as a local zip archive or as a static HTML file with inline CSS. Alternatively, an HTML can also be specified via URL.

While creating the corresponding Asset instance, the media type must be:
  • “application/zip”, if the input is a local zip archive.

  • “text/html”, if the input is a static HTML file with inline CSS

In case the input is a local zip archive, it must have the following structure:
  • The main HTML file must be named “index.html”.

  • “index.html” must exist at the top level of zip archive, not in a folder.

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.ZIP)
page_layout = PageLayout(page_height=11.5, page_width=8)
html_to_pdf_params =  HTMLtoPDFParams(page_layout=page_layout, include_header_footer=True)
html_to_pdf_job = HTMLtoPDFJob(input_asset=input_asset, html_to_pdf_params=html_to_pdf_params)
location = pdf_services.submit(html_to_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, HTMLtoPDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new HTMLtoPDFJob.

At least one of input_asset or input_url needs to be specified.

Parameters:
  • input_asset (Asset) – Asset object containing the input file. (Optional, use key-value)

  • input_url (str) – String representing the input URL. (Optional, use key-value)

  • html_to_pdf_params (HTMLtoPDFParams) – HTMLToPDFParams}. (Optional, use key-value)

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

InsertPagesJob

class adobe.pdfservices.operation.pdfjobs.jobs.insert_pages_job.InsertPagesJob(insert_pages_params: InsertPagesParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that can be used to insert pages of multiple PDF files into a base PDF file.

For more complex use cases, refer the CombinePDFJob.

Sample Usage:

base_file = open('SOURCE_PATH', 'rb')
base_input_stream = base_file.read()
base_file.close()
file_to_insert = open('SOURCE_PATH_1', 'rb')
input_stream_to_insert = file_to_insert.read()
file_to_insert.close()
credentials = ServicePrincipalCredentials(
    client_id=os.getenv('PDF_SERVICES_CLIENT_ID'),
    client_secret=os.getenv('PDF_SERVICES_CLIENT_SECRET')
)
pdf_services = PDFServices(credentials=credentials)
base_asset = pdf_services.upload(input_stream=base_input_stream,
                                 mime_type=MediaType.PDF)
asset_to_insert = pdf_services.upload(input_stream=input_stream_to_insert,
                              mime_type=MediaType.PDF)
page_ranges = PageRanges().add_range(1, 3)
insert_pages_params = InsertPagesParams(base_asset=base_asset)
insert_pages_params.add_pages_to_insert(input_asset=asset_to_insert, page_ranges=page_ranges, base_page=2)
insert_pages_job = InsertPagesJob(insert_pages_params=insert_pages_params)
location = pdf_services.submit(insert_pages_job)
pdf_services_response = pdf_services.get_job_result(location, InsertPagesResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new InsertPagesPDFJob instance.

Parameters:
  • insert_pages_params (InsertPagesParams) – Object containing the input files and the page numbers to insert at; can not be None.

  • output_asset (Asset) – Object representing the output asset. (Optional, use key-value) External assets can be set as output only when input is external asset as well

LinearizePDFJob

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

Bases: PDFServicesJob

A job that converts a PDF file into a linearized (also known as “web optimized”) PDF file. Such PDF files are optimized for incremental access in network environments.

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)
linearize_pdf_job = LinearizePDFJob(input_asset=input_asset)
location = pdf_services.submit(linearize_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, LinearizePDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new LinearizePDFJob instance.

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

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

OCRPDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.ocr_pdf_job.OCRPDFJob(input_asset: Asset, *, ocr_pdf_params: OCRParams | None = None, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that convert a PDF file into a searchable PDF file. Allows specifying OCRSupportedLocale and OCR Type.

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)
ocr_pdf_job = OCRPDFJob(input_asset=input_asset)
location = pdf_services.submit(ocr_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, OCRPDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new OCRPDFJob instance.

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

  • ocr_pdf_params (OCRParams) – OCRParams} object containing the OCR parameters. (Optional, use key-value)

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

PDFPropertiesJob

class adobe.pdfservices.operation.pdfjobs.jobs.pdf_properties_job.PDFPropertiesJob(input_asset: Asset, *, pdf_properties_params: PDFPropertiesParams | None = None)

Bases: PDFServicesJob

A job that is used to fetch properties from an input PDF file. The properties are returned in a dict.

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)
pdf_properties_params = PDFPropertiesParams(include_page_level_properties=True)
pdf_properties_job = PDFPropertiesJob(input_asset=input_asset, pdf_properties_params=pdf_properties_params)
location = pdf_services.submit(pdf_properties_job)
pdf_services_response = pdf_services.get_job_result(location, PDFPropertiesResult)
pdf_properties_result = pdf_services_response.get_result()

Constructs a new PDFPropertiesJob instance.

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

  • pdf_properties_params (PDFPropertiesParams) – PDFPropertiesParams object containing the properties to be fetched. (Optional, use key-value)

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

ProtectPDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.protect_pdf_job.ProtectPDFJob(input_asset: Asset, protect_pdf_params: PasswordProtectParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that is used for securing PDF document with password(s). The password(s) is used for encrypting the PDF document and setting the restriction on certain features like printing, editing and copying in the PDF document.

The supported algorithm for encrypting the PDF document are listed here. The EncryptionAlgorithm enum can be used to set the encryption algorithm.

  • AES-128

  • AES-256

For AES-128 encryption the password supports LATIN-I characters only. For AES-256 encryption the password supports Unicode character set.

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)
protect_pdf_params = PasswordProtectParams(
    user_password='password',
    encryption_algorithm=EncryptionAlgorithm.AES_256,
    content_encryption=ContentEncryption.ALL_CONTENT,
)
protect_pdf_job = ProtectPDFJob(input_asset=input_asset, protect_pdf_params=protect_pdf_params)
location = pdf_services.submit(protect_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, ProtectPDFResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new ProtectPDFJob instance.

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

  • protect_pdf_params (PasswordProtectParams) – ProtectPDFParams object containing the protect PDF parameters; can not be None.

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

RemoveProtectionJob

class adobe.pdfservices.operation.pdfjobs.jobs.remove_protection_job.RemoveProtectionJob(input_asset: Asset, remove_protection_params: RemoveProtectionParams, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that allows to remove password security from a PDF document.

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)
remove_protection_params = RemoveProtectionParams(password="password")
remove_protection_job = RemoveProtectionJob(input_asset=input_asset,
                                            remove_protection_params=remove_protection_params)
location = pdf_services.submit(remove_protection_job)
pdf_services_response = pdf_services.get_job_result(location, RemoveProtectionResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new RemoveProtectionJob instance.

Parameters:
  • input_asset (Asset) – The input asset for the job. (Mandatory, use key-value)

  • remove_protection_params (RemoveProtectionParams) – RemoveProtectionParams to set; can not be None.

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of RemoveProtectionJob.

Return type:

RemoveProtectionJob

ReorderPagesJob

class adobe.pdfservices.operation.pdfjobs.jobs.reorder_pages_job.ReorderPagesJob(reorder_pages_params: ReorderPagesParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that allows to rearrange pages in a PDF file according to the specified order.

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)
pages_to_reorder = PageRanges().add_range(3, 4)
                    .add_single_page(1)
reorder_pages_params = ReorderPagesParams(asset=input_asset, page_ranges=pages_to_reorder)
reorder_pages_job = ReorderPagesJob(reorder_pages_params=reorder_pages_params)
location = pdf_services.submit(reorder_pages_job)
pdf_services_response = pdf_services.get_job_result(location, ReorderPagesResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new ReorderPagesJob instance.

Parameters:
  • reorder_pages_params (ReorderPagesParams) – ReorderPagesParams to set; can not be None.

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of ReorderPagesJob.

Return type:

ReorderPagesJob

ReplacePagesJob

class adobe.pdfservices.operation.pdfjobs.jobs.replace_pages_job.ReplacePagesJob(replace_pages_params: ReplacePagesParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that allows specific pages in a PDF file to be replaced with pages from multiple PDF files.

Sample usage.

base_file = open('SOURCE_PATH', 'rb')
base_input_stream = base_file.read()
base_file.close()
file_1 = open('SOURCE_PATH', 'rb')
input_stream_1 = file_1.read()
file_1.close()
file_2 = open('SOURCE_PATH', 'rb')
input_stream_2 = file_2.read()
file_2.close()
credentials = ServicePrincipalCredentials(
    client_id=os.getenv('PDF_SERVICES_CLIENT_ID'),
    client_secret=os.getenv('PDF_SERVICES_CLIENT_SECRET')
)
pdf_services = PDFServices(credentials=credentials)
base_asset = pdf_services.upload(input_stream=base_input_stream,
                                  mime_type=MediaType.PDF)
asset_1 = pdf_services.upload(input_stream=input_stream_1,
                             mime_type=MediaType.PDF)
asset_2 = pdf_services.upload(input_stream=input_stream_2,
                              mime_type=MediaType.PDF)
page_ranges = PageRanges().add_range(3, 4)
                    .add_single_page(1)
replace_pages_params = ReplacePagesParams(base_asset=base_asset)
replace_pages_params.add_pages_to_replace(input_asset=asset_1, page_ranges=page_ranges, base_page=1)
replace_pages_params.add_pages_to_replace(input_asset=asset_2, base_page=3)
replace_pages_job = ReplacePagesJob(replace_pages_params=replace_pages_params)
location = pdf_services.submit(replace_pages_job)
pdf_services_response = pdf_services.get_job_result(location, ReplacePagesResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new ReplacePagesJob instance.

Parameters:
  • replace_pages_params (ReplacePagesParams) – ReplacePagesParams to set; can not be None.

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of ReplacePagesJob.

Return type:

ReplacePagesJob

RotatePagesJob

class adobe.pdfservices.operation.pdfjobs.jobs.rotate_pages_job.RotatePagesJob(input_asset: Asset, rotate_pages_params: RotatePagesParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that allows rotation of specific pages in a PDF file.

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)
rotate_pages_params = RotatePagesParams()
rotate_pages_params.add_angle_to_rotate(angle=Angle.ANGLE_90)
reorder_pages_job = RotatePagesJob(input_asset=input_asset, rotate_pages_params=rotate_pages_params)
location = pdf_services.submit(reorder_pages_job)
pdf_services_response = pdf_services.get_job_result(location, RotatePagesResult)
result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
stream_asset: StreamAsset = pdf_services.get_content(result_asset)

Constructs a new RotatePagesJob instance.

Parameters:
  • input_asset (Asset) – The input asset for the job; can not be None.

  • rotate_pages_params (RotatePagesParams) – RotatePagesParams} object containing the rotation angle and page ranges; can not be None.

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

SplitPDFJob

class adobe.pdfservices.operation.pdfjobs.jobs.split_pdf_job.SplitPDFJob(input_asset: Asset, split_pdf_params: SplitPDFParams, *, output_asset: Asset | None = None)

Bases: PDFServicesJob

A job that splits PDF document into multiple smaller documents by simply specifying either the number of files, pages per file, or page ranges.

Sample usage.

file = open('SOURCE_PATH', 'rb')
base_input_stream = base_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)
split_pdf_params = SplitPDFParams(page_count=2)
split_pdf_job = SplitPDFJob(input_asset, split_pdf_params)
location = pdf_services.submit(split_pdf_job)
pdf_services_response = pdf_services.get_job_result(location, SplitPDFResult)
result_assets = pdf_services_response.get_result().get_assets()

Constructs a new SplitPDFJob instance.

Parameters:
  • input_asset (Asset) – The input asset for the job; can not be None.

  • split_pdf_params (SplitPDFParams) – SplitPDFParams to set; can not be None.

  • output_asset (ExternalAsset) – The output asset for the job. (Optional, use key-value)

Returns:

A new instance of SplitPDFJob.

Return type:

SplitPDFJob