Skip to content

SDKs

Choose a client for the language you already use. HTTP clients call a PressJet server with its base URL and a bearer key. Server-side code should keep that key in the application's secret configuration.

SDK Run options Start here
JavaScript / TypeScript HTTP client or local Node.js renderer on supported Linux architectures TypeScript SDK
Python HTTP client. Linux platform wheels also install the CLI. Python SDK
Go HTTP client Go SDK
PHP HTTP client PHP SDK
Other languages HTTP and JSON HTTP API

Find versioned packages and copyable commands in Install PressJet.

Browser and edge

The WebAssembly SDK renders in-process with HTML or the native document format. Use its framework adapters if your templates are already React, Preact, Vue, or Svelte components. See installation and the WASM SDK guide for loading the module and rendering.

TypeScript and JavaScript

With the package installed, send the content of invoice.html to your API. The constructor reads PRESSJET_API_KEY and PRESSJET_URL from the server process environment.

import { readFile, writeFile } from "node:fs/promises";
import { Pressjet } from "pressjet";

const pressjet = new Pressjet();
const html = await readFile("invoice.html", "utf8");
await writeFile("invoice.pdf", await pressjet.html(html));

Python

import os
from pathlib import Path
from pressjet import Client

html = Path("invoice.html").read_text(encoding="utf-8")
with Client(api_key=os.environ["PRESSJET_API_KEY"], base_url="http://127.0.0.1:8080") as client:
    Path("invoice.pdf").write_bytes(client.html(html))

Go

package main

import (
    "context"
    "log"
    "os"

    pressjet "github.com/tonysantana1492/pressjet/sdks/go"
)

func main() {
    html, err := os.ReadFile("invoice.html")
    if err != nil {
        log.Fatal(err)
    }
    pdf, err := pressjet.NewClient().HTML(context.Background(), string(html), nil)
    if err != nil {
        log.Fatal(err)
    }
    if err := os.WriteFile("invoice.pdf", pdf, 0600); err != nil {
        log.Fatal(err)
    }
}

The Go client reads PRESSJET_API_KEY and PRESSJET_URL from the process environment.

PHP

See the complete PHP example for rendering a local HTML file through Composer. Use the same client method with the output of a PHP view in your application.