Skip to content
Inkoxide

Search covers every page and heading of the docs. Use ↑ ↓ and ↵.

Quick start

Install @inkoxide/vue and render a receipt from a Vue component.

Edit this page

Vue templates to PDF with the Inkoxide engine, in Node and in the browser. You write Document, Page, View, Text, Table and the other components in single-file components or render functions, style them with style or Tailwind classes, and get a PDF: the same PDF, byte for byte, as the same document written for @inkoxide/react.

The guide says how Vue writes each part of a document, and the API.

Part of Inkoxide. Requires Node.js 22 or later and Vue 3.5 or later; ES modules only.

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');
receipt.pdf
A6 receipt PDF: 'Receipt for Ada Lovelace', three items with prices and a bold total.

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.

Synced from packages/vue/README.md in the inkoxide repository.