Python¶
Install the package with pip install kolinsky.
from pathlib import Path
import kolinsky
result = kolinsky.render(Path("hello.html"))
for d in result.diagnostics:
print(f"{d.code}: {d.message}")
Path("hello.pdf").write_bytes(result.pdf)
kolinsky.render takes HTML text, bytes, a path or a URL and returns the PDF bytes with the diagnostics.
PDF options are a kolinsky.PdfOptions or a mapping with the same keys:
from pathlib import Path
import kolinsky
result = kolinsky.render(
Path("hello.html"),
pdf={"title": "Invoice 2026-042", "standards": ("ua-1",), "tagged": True},
)
Path("invoice.pdf").write_bytes(result.pdf)
kolinsky.Engine holds fonts and a resource loader for many documents, Engine.layout returns a
Document whose pages and boxes can be queried before the PDF is written, and render_async runs in an
asyncio loop. Errors are subclasses of kolinsky.KolinskyError; diagnostics are also logged on the
kolinsky logger.