Skip to main content

Official Python SDK for the DocRenders API

Project description

docrenders-sdk (Python)

Official Python SDK for the DocRenders API. No dependencies — uses the standard library only.

Installation

pip install docrenders-sdk

Usage

import os
from docrenders import DocRendersClient, RenderRequest, RenderFileRequest, RenderOptions

client = DocRendersClient(os.environ["PDFGEN_API_KEY"])

# Render to raw bytes
pdf = client.render(RenderRequest(
    markdown="# Invoice\n\nDue: **$1,200**",
    template="invoice",
    options=RenderOptions(format="A4"),
))

# Render and get a signed download URL (expires in 15 min)
result = client.render_signed_url(RenderRequest(markdown="# Report"))
print(result.url)

# Upload a file
with open("invoice.md", "rb") as f:
    pdf = client.render_file(RenderFileRequest(
        filename="invoice.md",
        content=f.read(),
    ))

# Check usage
usage = client.usage()
print(f"{usage.renders_used} / {usage.renders_limit} renders used")

Error handling

from docrenders import DocRendersClient, DocRendersError, RenderRequest

try:
    pdf = client.render(RenderRequest(markdown="# Hello"))
except DocRendersError as e:
    print(e.code, str(e))  # e.g. "quota_exceeded"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docrenders_sdk-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docrenders_sdk-0.1.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file docrenders_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: docrenders_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for docrenders_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 78b4e29f6b9525169b6bcdb677a6d31da8e796e055d497de144604e76d60860e
MD5 a01e8d4bff44d1ed37c0835d39c6e2f0
BLAKE2b-256 89bc5dcdc49d83847cf0b659a91aa1b35d912873797023b7e7dfecccc6bf0863

See more details on using hashes here.

File details

Details for the file docrenders_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for docrenders_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d696608089de72b221e8fc7368bdd6edea70384f193783f1c86210812214a11
MD5 f211516d727d2c8420fdf53fc38575f2
BLAKE2b-256 62798368bef190117a3c4a20e307fabd6140d2f888622ba98a06dd2867f3b299

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page