Skip to main content

DInk Python Library

The DInk Python library provides a pythonic interface to the DInk API. It includes an API client class, and a set of resource classes.

Installation

pip install dink

Requirements

  • Python 3.7+

Usage

import dink
import zipfile


client = dink.Client('your_api_key...')

assets = io.BytesIO()
with zipfile.ZipFile(assets, mode='w', compression=zipfile.ZIP_DEFLATED) as z:

    z.write('includes/footer.html')
    z.write('css/document.css')
    z.write('images/logo.png')
    z.write('fonts/company-font.otf')

assets.seek(0)

pdfs = dink.resources.PDF.create(
    client,
    template_html='''
<html>
    <head>
        <title>{{ title }}</title>
        <link
            rel="stylesheet"
            type="text/css"
            media="print"
            href="file://css/document.css"
        >
    </head>
    <body>
        <img src="images/logo.png" alt="logo">
        <h1>{{ title }}</h1>
        <main>
            {{ name }} you worked {{ hours_worked }} hours this week you
            {% if hours_worked > 40 %}
                star!
            {% else %}
                lazy bum!
            {% endif %}

            <img
                src="chart://hours_chart"
                alt="Hours worked each day this week"
                >
        </main>
        {% include 'includes/footer.html' %}
    </body>
</html>
    ''',
    document_args={
        'burt': {
            'hours_worked': 10,
            'hours_chart': dink.charts.BarChart(
                data=[{'data':  [1, 1, 2, 4, 2]}],
                labels=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
                spacing=0.2
            ).to_json_type()
        },
        'harry': {
            'hours_worked': 44,
            'hours_chart': dink.charts.BarChart(
                data=[{'data':  [8, 8, 10, 8, 10]}],
                labels=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
                spacing=0.2
            ).to_json_type()
        }
    },
    global_args={
        'title': 'Weekly sales report'
    },
    assets=assets
)

print(pdfs['burt'].store_key)

>> 'burt.ue32uw.pdf'

Metadata

Release files for DInk 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for DInk 0.0.5
File Size Uploaded Provenance Actions
DInk-0.0.5.tar.gz 7.4 kB Without provenance Details for DInk-0.0.5.tar.gz

Release files / DInk-0.0.5.tar.gz

Download URL DInk-0.0.5.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
47bbe71da0b4c4dbdfecb9221ba065bae5a5edaca428ced62b9ea5ed4c04f199
BLAKE2b-256 checksum
How to use checksums
4034afacc638a812436a609211cdb3b6bf8403fc220bbb66b6fe21d397e36071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.17

Security for DInk 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page