Getting started
Install the package for your framework and render a first PDF, or render one from a JSON document tree.
npm install @inkoxide/react
To style with Tailwind classes (className), as the example does, add:
npm install @inkoxide/tailwind
Save this as receipt.tsx:
/** @jsxRuntime automatic */
import { Document, Page, renderToFile, Text, View } from '@inkoxide/react';
interface Line {
name: string;
amount: number;
}
export default function Receipt({ customer, lines }: { customer: string; lines: Line[] }) {
const total = lines.reduce((sum, l) => sum + l.amount, 0);
return (
<Document title={`Receipt for ${customer}`}>
<Page size="A6" className="p-8 text-xs text-gray-900">
<Text className="text-lg font-bold">Receipt</Text>
<Text className="mb-4 text-gray-500">for {customer}</Text>
{lines.map((l) => (
<View key={l.name} className="flex-row justify-between border-b border-gray-200 py-1.5">
<Text>{l.name}</Text>
<Text>${l.amount.toFixed(2)}</Text>
</View>
))}
<View className="mt-3 flex-row justify-between font-bold">
<Text>Total</Text>
<Text>${total.toFixed(2)}</Text>
</View>
</Page>
</Document>
);
}
export const sample = {
customer: 'Ada Lovelace',
lines: [
{ name: 'Espresso', amount: 3.2 },
{ name: 'Almond croissant', amount: 4.5 },
{ name: 'Sparkling water', amount: 2 },
],
};
renderToFile(<Receipt {...sample} />, 'receipt.pdf');
Run it with npx tsx receipt.tsx, which writes receipt.pdf:

Switch to Layout for the boxes the engine laid out.
Drawn by the engine’s debug option, sizes in points.
In a server, renderToBuffer(<Receipt … />) returns the bytes to send, and
renderToStream(<Receipt … />) a stream to pipe into the response.
npm install @inkoxide/vue vue
<!-- Receipt.vue -->
<script setup lang="ts">
import { Document, Page, Text, View } from '@inkoxide/vue';
const props = defineProps<{ customer: string; lines: { name: string; amount: number }[] }>();
const total = props.lines.reduce((sum, l) => sum + l.amount, 0);
</script>
<template>
<Document :title="`Receipt for ${customer}`">
<Page size="A6" class="p-8 text-xs text-gray-900">
<Text class="text-lg font-bold">Receipt</Text>
<Text class="mb-4 text-gray-500">for {{ customer }}</Text>
<View v-for="l in lines" :key="l.name" class="flex-row justify-between border-b border-gray-200 py-1.5">
<Text>{{ l.name }}</Text>
<Text>${{ l.amount.toFixed(2) }}</Text>
</View>
<View class="mt-3 flex-row justify-between font-bold">
<Text>Total</Text>
<Text>${{ total.toFixed(2) }}</Text>
</View>
</Page>
</Document>
</template>
import { h } from 'vue';
import { renderToFile } from '@inkoxide/vue';
import Receipt from './Receipt.vue';
await renderToFile(h(Receipt, { customer: 'Ada Lovelace', lines: [{ name: 'Espresso', amount: 3.2 }] }), 'receipt.pdf');

Switch to Layout for the boxes the engine laid out.
Drawn by the engine’s debug option, sizes in points.
renderToBuffer, renderToFile and renderToStream take a VNode (h(Receipt, props)) or a
component. Classes need @inkoxide/tailwind.
npm install @inkoxide/svelte svelte
<!-- Receipt.svelte -->
<script lang="ts">
import { Document, Page, Text, View } from '@inkoxide/svelte';
let { customer, lines }: { customer: string; lines: { name: string; amount: number }[] } = $props();
const total = $derived(lines.reduce((sum, l) => sum + l.amount, 0));
</script>
<Document title={`Receipt for ${customer}`}>
<Page size="A6" class="p-8 text-xs text-gray-900">
<Text class="text-lg font-bold">Receipt</Text>
<Text class="mb-4 text-gray-500">for {customer}</Text>
{#each lines as l (l.name)}
<View class="flex-row justify-between border-b border-gray-200 py-1.5">
<Text>{l.name}</Text>
<Text>${l.amount.toFixed(2)}</Text>
</View>
{/each}
<View class="mt-3 flex-row justify-between font-bold">
<Text>Total</Text>
<Text>${total.toFixed(2)}</Text>
</View>
</Page>
</Document>
// A SvelteKit endpoint, or any server code built with Vite.
import { renderToBuffer } from '@inkoxide/svelte';
import Receipt from './Receipt.svelte';
const pdf = await renderToBuffer({ component: Receipt, props: { customer: 'Ada Lovelace', lines: [] } });

Switch to Layout for the boxes the engine laid out.
Drawn by the engine’s debug option, sizes in points.
renderToBuffer, renderToFile and renderToStream take a component with its props, or a
component alone. They render it with svelte/server, so the component must be compiled for the
server, as SvelteKit and Vite's SSR do. Classes need
@inkoxide/tailwind.
npm install @inkoxide/angular
import { Component, CUSTOM_ELEMENTS_SCHEMA, input } from '@angular/core';
import { renderToFile } from '@inkoxide/angular';
@Component({
selector: 'app-receipt',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<ink-document [title]="'Receipt for ' + customer()">
<ink-page size="A6" class="p-8 text-xs text-gray-900">
<ink-text class="text-lg font-bold">Receipt</ink-text>
<ink-text class="mb-4 text-gray-500">for {{ customer() }}</ink-text>
@for (l of lines(); track l.name) {
<ink-view class="flex-row justify-between border-b border-gray-200 py-1.5">
<ink-text>{{ l.name }}</ink-text>
<ink-text>\${{ l.amount.toFixed(2) }}</ink-text>
</ink-view>
}
</ink-page>
</ink-document>
`,
})
export class Receipt {
readonly customer = input.required<string>();
readonly lines = input.required<{ name: string; amount: number }[]>();
}
await renderToFile(
{ component: Receipt, inputs: { customer: 'Ada Lovelace', lines: [{ name: 'Espresso', amount: 3.2 }] } },
'receipt.pdf',
);

Switch to Layout for the boxes the engine laid out.
Drawn by the engine’s debug option, sizes in points.
renderToBuffer, renderToFile and renderToStream take a component with the values of its
inputs, or a component alone. Classes need
@inkoxide/tailwind.
The template is compiled like any other: by your Angular build (the CLI, Analog, ng build of a
server), or just in time in a plain Node script, with import '@angular/compiler'; first (signal
inputs need the AOT compiler; use @Input() there).
With JSON
import { readFileSync, writeFileSync } from 'node:fs';
import { registerFont, render } from 'inkoxide';
registerFont('Inter-Bold', readFileSync('Inter-Bold.ttf'));
const doc = {
version: 1,
fonts: [{ id: 'Inter-Bold', family: 'Inter', weight: 700 }],
pages: [
{
size: { width: 595.28, height: 841.89 },
margin: { top: 56, right: 56, bottom: 56, left: 56 },
children: [{ type: 'text', runs: [{ text: 'Hello, PDF', font: 'Inter-Bold', size: 28 }] }],
},
],
};
writeFileSync('hello.pdf', await render(JSON.stringify(doc)));
The document tree is a fully resolved description of boxes, text, images and tables, as JSON or
MessagePack. @inkoxide/schema has its TypeScript types and JSON Schema.
Platforms
Prebuilt binaries; npm installs the one for the current platform. The packages are ES modules.
The Node packages declare Node.js 22 or later (engines), and CI tests them on Node 22.
| OS | Architectures |
|---|---|
| macOS | arm64, x64 |
| Linux | x64 (glibc 2.35+ and musl), arm64 (glibc 2.35+) |
| Windows | x64 |
In browsers (current Chrome, Edge, Firefox and Safari), the engine is WebAssembly
(@inkoxide/wasm), and the browser entry of each front end (@inkoxide/react/browser,
@inkoxide/vue/browser, …) renders in a Web Worker; see
In the browser.
Synced from README.md in the inkoxide repository.
