pdftools_sdk.document_assembly.document_assembler

Classes

DocumentAssembler(out_stream, out_options, ...)

The class for splitting or merging PDF documents

class pdftools_sdk.document_assembly.document_assembler.DocumentAssembler(out_stream: io.IOBase, out_options: OutputOptions | None, conformance: Conformance | None)[source]

Bases: _NativeObject

The class for splitting or merging PDF documents

__init__(out_stream: io.IOBase, out_options: OutputOptions | None, conformance: Conformance | None)[source]
Parameters:
  • outStream (io.IOBase) – The stream to which the output PDF is written

  • outOptions (Optional[OutputOptions]) – The PDF output options, e.g. to encrypt the output document.

  • conformance (Optional[Conformance]) –

    The required conformance level of the PDF document. Adding pages or content from incompatible documents or using incompatible features will lead to a conformance error.

    When using None, the conformance is determined automatically, based on the conformance of the input documents used in the pdftools_sdk.document_assembly.document_assembler.DocumentAssembler.append method and the requirements of the used features.

Raises:
append(in_doc: Document, first_page: int | None = None, last_page: int | None = None, document_copy_options: DocumentCopyOptions | None = None, page_copy_options: PageCopyOptions | None = None) → None[source]

This method copies document properties and a range of pages from inDoc.

Parameters:
  • inDoc (Document)

  • firstPage (Optional[int]) –

    Optional parameter denoting the index of the first page to be copied. This index is one-based. If set, the number must be in the range of 1 (first page) to pdftools_sdk.pdf.document.Document.page_count (last page).

    If not set, 1 is used.

  • lastPage (Optional[int]) –

    Optional parameter denoting the index of the last page to be copied. This index is one-based. If set, the number must be in the range of 1 (first page) to pdftools_sdk.pdf.document.Document.page_count (last page).

    If not set, pdftools_sdk.pdf.document.Document.page_count is used.

  • documentCopyOptions (Optional[DocumentCopyOptions])

  • pageCopyOptions (Optional[PageCopyOptions])

Raises:
  • pdftools_sdk.license_error.LicenseError – The license check has failed.

  • ValueError – The firstPage or lastPage are not in the allowed range.

  • ValueError – If the method has already been called with any of the following properties set to True: - pdftools_sdk.document_assembly.document_copy_options.DocumentCopyOptions.copy_metadata - pdftools_sdk.document_assembly.document_copy_options.DocumentCopyOptions.copy_viewer_settings - pdftools_sdk.document_assembly.document_copy_options.DocumentCopyOptions.copy_output_intent

  • pdftools_sdk.conformance_error.ConformanceError – The conformance level of the input document is not compatible with the conformance level of the output document.

  • pdftools_sdk.conformance_error.ConformanceError – The explicitly requested conformance level is PDF/A Level A (pdftools_sdk.pdf.conformance.Conformance.PDFA1A, pdftools_sdk.pdf.conformance.Conformance.PDFA2A, or pdftools_sdk.pdf.conformance.Conformance.PDFA3A) and the copy option pdftools_sdk.document_assembly.page_copy_options.PageCopyOptions.copy_logical_structure is set to False.

  • StateError – If pdftools_sdk.document_assembly.document_assembler.DocumentAssembler.assemble has already been called.

  • pdftools_sdk.processing_error.ProcessingError – The processing has failed.

assemble() → Document[source]

Assemble the input documents

The input documents appended with pdftools_sdk.document_assembly.document_assembler.DocumentAssembler.append are assembled into the output PDF.

Returns:

The assembled PDF, which can be used as a new input for further processing.

Return type:

Document

Raises:

StateError – If pdftools_sdk.document_assembly.document_assembler.DocumentAssembler.assemble has already been called.