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.2.0.tar.gz (4.4 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.2.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docrenders_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 4.4 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.2.0.tar.gz
Algorithm Hash digest
SHA256 35287609dc9dbda76adf8bdd33e149a8703cd2f084d180ad45e0bb78a17d2fda
MD5 8905319d53234c78c9f60e7ccc827f7b
BLAKE2b-256 41ada69b341b95936f4fe87085419d4b0f8b098d6d31fc2cad0c0587fda14bed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for docrenders_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d83a2f4e7c7891121461c4526dd2fcf8595aa0d81c9b352b33f74c1b9dd31a31
MD5 a7bc213b5b2fe6817639d41d284d8154
BLAKE2b-256 107b31ecff2175f431fa43ab6be88042ecb1322a0295003f6659623f7458b098

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