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

Uploaded Python 3

File details

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

File metadata

  • Download URL: docrenders_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 4.5 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.1.tar.gz
Algorithm Hash digest
SHA256 395f7a102c62033dd4332cee50139a576aa3e5090caf6a1876c61eeef6c262e0
MD5 3c620a4b8b16fa4b7b2ab58b31ea2481
BLAKE2b-256 07a7266ae3f65c23d7220357a3aaa40ce1473290017a5e968b48a2262372e9a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: docrenders_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for docrenders_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 83c5fbed109d6be20f69c4de4a570d136315e9512caa8cb142aa7683fbdbe181
MD5 ebf0817862dd21ef1c8e5e380b357afc
BLAKE2b-256 0d3b88dd7483c2e3f18ce11a54931588ae8772a45522c08ae6eff853ce9ae48a

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