The engine as a program
The engine for your servers as a program: a command that prints a file, or a local server with the API's own request, at the engine's full speed.
The program is sent on request: write to hello@reflowpdf.com.
reflowpdf print invoice.html -o invoice.pdfThe archive holds the program (bin/reflowpdf), its fonts, hyphenation and printer profiles (share/reflowpdf, kept beside bin), LICENSE.txt, README.md and THIRD-PARTY.md. It needs nothing else installed: no browser, no runtime.
Print a file#
reflowpdf print invoice.html -o invoice.pdf
reflowpdf print report.html -o report.pdf --options '{"pdf_ua": 1, "paper": {"size": "Letter"}}'
cat page.html | reflowpdf print - -o - > page.pdf--options takes the options of the API, by the same names (options). The document reads files only under its own folder and the folders given with --root; it fetches nothing from the network unless --allow-remote is given. As the API does, the program sets A4 paper with 20 mm margins below the document and breaks a word wider than its line; --no-product-defaults leaves both out.
Run it as a server#
reflowpdf serve --listen 127.0.0.1:8080
curl -H 'content-type: application/json' -d '{"html": "<h1>Hi</h1>"}' http://127.0.0.1:8080/v1/pdf -o hi.pdfserve answers POST /v1/pdf with the body and options of the API, and refuses what the API refuses, in its words; GET /v1/health says how it stands. It prints as many documents at once as the machine has cores. Templates with data and printing by url are the API's. Keep it on the loopback or a private network: it has no keys of its own.
From your code#
The server speaks the API's POST /v1/pdf, so the SDKs print through it: point them at it with REFLOWPDF_BASE_URL. The server takes no key; the SDKs want one in REFLOWPDF_API_KEY, and the program reads the same variable for its license.
curl -H 'content-type: application/json' -d '{"html": "<h1>Hi</h1>", "options": {"pdf_ua": 1}}' http://127.0.0.1:8080/v1/pdf -o hi.pdf// REFLOWPDF_BASE_URL=http://127.0.0.1:8080
import { ReflowPDF } from '@reflowpdf/sdk'
const reflow = new ReflowPDF()
const pdf = await reflow.pdf.create({ html, options: { pdf_ua: 1 } }) // pdf.bytes# REFLOWPDF_BASE_URL=http://127.0.0.1:8080
from reflowpdf import ReflowPDF
client = ReflowPDF()
client.pdf.create(html=html, options={"pdf_ua": 1}).save("out.pdf")// REFLOWPDF_BASE_URL=http://127.0.0.1:8080
use ReflowPDF\ReflowPDF;
$reflow = new ReflowPDF();
$reflow->pdf->create(['html' => $html, 'options' => ['pdf_ua' => 1]])->save('out.pdf');Without a server, run the command with the HTML on its input and the PDF on its output: reflowpdf print - -o -. A process per document starts the engine each time; for many documents the server is faster.
The license#
Without a license every page carries a small “ReflowPDF trial” mark. A license is bought in the editor (account menu, Engine licenses) and covers this program as it covers the WebAssembly package (terms): Start one installation, Business up to five — a server, virtual machine or running container is one. Give the program the license's key and the license owner's API key; it fetches the license's token, keeps it in its cache folder (REFLOWPDF_CACHE, else the user's) and fetches it again before it ends:
export REFLOWPDF_LICENSE_KEY=rpdfl_…
export REFLOWPDF_API_KEY=rpdf_…
reflowpdf serve --listen 127.0.0.1:8080A machine without network access gets the token another way: fetch it where there is network (GET https://api.reflowpdf.com/v1/engine/license?key=rpdfl_… with the API key) and give it to the program in REFLOWPDF_LICENSE_TOKEN. A token lasts up to 42 days.
Speed#
The program is the engine compiled for the machine. On the documents of our speed comparison, it printed three to four times faster than the WebAssembly package in Node.js on the same server.