Python SDK

The Python SDK provides a client for integrating PDFGate API endpoints into your Python applications.

Source code: github.com/pdfgate/pdfgate-sdk-python
Package: pypi.org/project/pdfgate

Installation

Install the package with pip, then initialize the client with your API key.

1pip install pdfgate

Quick start

The example below generates a PDF from a URL and prints the resulting document id.

1import os23from pdfgate import PDFGate, GeneratePDFParams456client = PDFGate(api_key=os.getenv("PDFGATE_API_KEY"))7params = GeneratePDFParams(url="https://example.com")8document = client.generate_pdf(params)910print(document["id"])

Sync and async usage

The SDK exposes both sync and async variants. Async methods use the same interface and add an _async suffix.

1document_response = client.get_document(GetDocumentParams(document_id=document_id))23# VS45document_response = await client.get_document_async(GetDocumentParams(document_id=document_id))

Download a file

Use get_file to retrieve the file bytes and save them locally.

1file_content = client.get_file(GetFileParams(document_id=document_id))23with open("output.pdf", "wb") as f:4  f.write(file_content)

Core methods

MethodPurpose
generate_pdfGenerate a PDF from HTML or a public URL.
get_documentRetrieve document metadata and file information.
get_fileDownload the raw PDF bytes for a stored document.
upload_fileUpload a PDF file for later transformations.
flatten_pdfFlatten form fields into a non-editable PDF.
compress_pdfCompress a PDF and return the resulting document record.
watermark_pdfApply image or text watermarks to a document.
protect_pdfEncrypt a PDF and apply access restrictions.
extract_pdf_form_dataRead field values from a fillable PDF.
create_envelopeCreate a signing envelope from one or more documents.
send_envelopeSend an envelope to its recipients for signing.
get_envelopeRetrieve the current status of an envelope.
void_envelopeVoid an envelope so it can no longer be signed.
delete_envelopeDelete an envelope and remove its signed documents.
create_embed_linkCreate a short-lived signing link for an embedded recipient.
create_recipientStore a recipient for reuse across envelopes.
list_recipientsList stored recipients by email.
get_recipientRetrieve a stored recipient by ID.
update_recipientUpdate a stored recipient's name or metadata.
delete_recipientDelete a stored recipient. Refused while a stored signature is active or an enrolment is pending.
request_recipient_signatureAutomatic signing. Email the recipient a link to store a reusable signature.
remove_recipient_signatureRemove a recipient's stored signature or cancel a pending enrolment.

Related documentation

Use the SDK together with the main API documentation for request parameters, endpoint behavior, and workflow guides such as webhooks and PDF form fields.

For a complete, tested walkthrough of one operation, see how to flatten a PDF in Python.

This website uses cookies to offer a better browsing experience. By clicking on the "Accept" button you accept our Cookie policy.