Skip to content
Inkoxide

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

Page

Pages, the headers and footers repeated on them, page numbers and page breaks.

Edit this page

Import them from @inkoxide/react, @inkoxide/vue or @inkoxide/svelte; an Angular template writes them as <ink-page>, <ink-header>, <ink-footer>, <ink-page-number>, <ink-total-pages>, <ink-page-break>, injectPage(). Examples, and how these components work together, are in the guide.

Page

One page layout; content flows over as many sheets as it needs. size (a preset such as "A4", "letter" or "A4-landscape", [width, height], { width, height }, or [width] or one length for a square), orientation, margin. Padding on a page is its margin; a percentage is of the page width, on every side, as in CSS. A bg-* class sets its background, which is opaque: a colour with opacity (bg-black/5, bg-transparent) is drawn on white.

import { Document, Page, Text } from '@inkoxide/react';

export default function Example() {
  return (
    <Document>
      <Page size="A7-landscape" margin={20} className="bg-stone-100">
        <Text className="text-lg font-bold">An A7 page, sideways</Text>
        <Text className="mt-1 text-gray-500">Its margins are 20 points on every side.</Text>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Document, Page, Text } from '@inkoxide/vue';
</script>

<template>
  <Document>
    <Page size="A7-landscape" :margin="20" class="bg-stone-100">
      <Text class="text-lg font-bold">An A7 page, sideways</Text>
      <Text class="mt-1 text-gray-500">Its margins are 20 points on every side.</Text>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Document, Page, Text } from '@inkoxide/svelte';
</script>

<Document>
  <Page size="A7-landscape" margin={20} class="bg-stone-100">
    <Text class="text-lg font-bold">An A7 page, sideways</Text>
    <Text class="mt-1 text-gray-500">Its margins are 20 points on every side.</Text>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page size="A7-landscape" [margin]="20" class="bg-stone-100">
        <ink-text class="text-lg font-bold">An A7 page, sideways</ink-text>
        <ink-text class="mt-1 text-gray-500">Its margins are 20 points on every side.</ink-text>
      </ink-page>
    </ink-document>
  `,
})
export class Example {}
The PDF this example renders.
PropTypeDefaultDescription
sizePageSizeA4A preset ('A4', 'letter', 'A5-landscape'), [width, height], { width, height }, or [width] or a single length for a square page. Lengths are points or strings with a unit ('210mm').
orientation'portrait' | 'landscape'Turns the size sideways (landscape) or upright (portrait).
marginEdges<Length>One length for all sides or per side (points, or '15mm').
classNamestringText utilities set the defaults inherited by the page's content; bg-* sets the page background, which is opaque: a colour with opacity is drawn on white.
styleStyle
debugbooleanOutlines the page's margins and the boxes of every element on it, header and footer included.

Repeated on every page, in the top or bottom margin.

import { Document, Header, Page, Text } from '@inkoxide/react';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 160]} margin={{ top: 44, right: 24, bottom: 24, left: 24 }}>
        <Header className="flex-row justify-between border-b border-gray-200 pb-1.5 text-xs text-gray-500">
          <Text>Northwind Labs</Text>
          <Text>Annual report 2026</Text>
        </Header>
        <Text>The header sits in the top margin, and repeats on every page.</Text>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Document, Header, Page, Text } from '@inkoxide/vue';
</script>

<template>
  <Document>
    <Page :size="[320, 160]" :margin="{ top: 44, right: 24, bottom: 24, left: 24 }">
      <Header class="flex-row justify-between border-b border-gray-200 pb-1.5 text-xs text-gray-500">
        <Text>Northwind Labs</Text>
        <Text>Annual report 2026</Text>
      </Header>
      <Text>The header sits in the top margin, and repeats on every page.</Text>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Document, Header, Page, Text } from '@inkoxide/svelte';
</script>

<Document>
  <Page size={[320, 160]} margin={{ top: 44, right: 24, bottom: 24, left: 24 }}>
    <Header class="flex-row justify-between border-b border-gray-200 pb-1.5 text-xs text-gray-500">
      <Text>Northwind Labs</Text>
      <Text>Annual report 2026</Text>
    </Header>
    <Text>The header sits in the top margin, and repeats on every page.</Text>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[320, 160]" [margin]="{ top: 44, right: 24, bottom: 24, left: 24 }">
        <ink-header class="flex-row justify-between border-b border-gray-200 pb-1.5 text-xs text-gray-500">
          <ink-text>Northwind Labs</ink-text>
          <ink-text>Annual report 2026</ink-text>
        </ink-header>
        <ink-text>The header sits in the top margin, and repeats on every page.</ink-text>
      </ink-page>
    </ink-document>
  `,
})
export class Example {}
The PDF this example renders.

It also takes the shared props className, style, id, debug.

Repeated on every page, in the top or bottom margin.

import { Document, Footer, Page, PageNumber, Text, TotalPages } from '@inkoxide/react';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 160]} margin={{ top: 24, right: 24, bottom: 44, left: 24 }}>
        <Text>The footer sits in the bottom margin, and repeats on every page.</Text>
        <Footer className="flex-row justify-between border-t border-gray-200 pt-1.5 text-xs text-gray-500">
          <Text>Northwind Labs</Text>
          <Text>
            Page <PageNumber /> of <TotalPages />
          </Text>
        </Footer>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Document, Footer, Page, PageNumber, Text, TotalPages } from '@inkoxide/vue';
</script>

<template>
  <Document>
    <Page :size="[320, 160]" :margin="{ top: 24, right: 24, bottom: 44, left: 24 }">
      <Text>The footer sits in the bottom margin, and repeats on every page.</Text>
      <Footer class="flex-row justify-between border-t border-gray-200 pt-1.5 text-xs text-gray-500">
        <Text>Northwind Labs</Text>
        <Text>
          Page <PageNumber /> of <TotalPages /></Text>
      </Footer>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Document, Footer, Page, PageNumber, Text, TotalPages } from '@inkoxide/svelte';
</script>

<Document>
  <Page size={[320, 160]} margin={{ top: 24, right: 24, bottom: 44, left: 24 }}>
    <Text>The footer sits in the bottom margin, and repeats on every page.</Text>
    <Footer class="flex-row justify-between border-t border-gray-200 pt-1.5 text-xs text-gray-500">
      <Text>Northwind Labs</Text>
      <Text>
        Page <PageNumber /> of <TotalPages /></Text>
    </Footer>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[320, 160]" [margin]="{ top: 24, right: 24, bottom: 44, left: 24 }">
        <ink-text>The footer sits in the bottom margin, and repeats on every page.</ink-text>
        <ink-footer class="flex-row justify-between border-t border-gray-200 pt-1.5 text-xs text-gray-500">
          <ink-text>Northwind Labs</ink-text>
          <ink-text>
            Page <ink-page-number /> of <ink-total-pages /></ink-text>
        </ink-footer>
      </ink-page>
    </ink-document>
  `,
})
export class Example {}
The PDF this example renders.

It also takes the shared props className, style, id, debug.

PageNumber

The current page number. Only inside Text.

import { Document, Page, PageNumber, Text } from '@inkoxide/react';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 120]} className="p-6">
        <Text className="text-lg font-bold">
          This is page <PageNumber />
        </Text>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Document, Page, PageNumber, Text } from '@inkoxide/vue';
</script>

<template>
  <Document>
    <Page :size="[320, 120]" class="p-6">
      <Text class="text-lg font-bold">
        This is page <PageNumber /></Text>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Document, Page, PageNumber, Text } from '@inkoxide/svelte';
</script>

<Document>
  <Page size={[320, 120]} class="p-6">
    <Text class="text-lg font-bold">
      This is page <PageNumber /></Text>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[320, 120]" class="p-6">
        <ink-text class="text-lg font-bold">
          This is page <ink-page-number /></ink-text>
      </ink-page>
    </ink-document>
  `,
})
export class Example {}
The PDF this example renders.

It takes no props.

TotalPages

The total page count. Only inside Text.

import { Document, Page, PageBreak, PageNumber, Text, TotalPages } from '@inkoxide/react';

export default function Example() {
  return (
    <Document>
      <Page size={[200, 120]} className="p-6">
        <Text className="font-bold">
          Page <PageNumber /> of <TotalPages />
        </Text>
        <PageBreak />
        <Text className="font-bold">
          Page <PageNumber /> of <TotalPages />
        </Text>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Document, Page, PageBreak, PageNumber, Text, TotalPages } from '@inkoxide/vue';
</script>

<template>
  <Document>
    <Page :size="[200, 120]" class="p-6">
      <Text class="font-bold">
        Page <PageNumber /> of <TotalPages /></Text>
      <PageBreak />
      <Text class="font-bold">
        Page <PageNumber /> of <TotalPages /></Text>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Document, Page, PageBreak, PageNumber, Text, TotalPages } from '@inkoxide/svelte';
</script>

<Document>
  <Page size={[200, 120]} class="p-6">
    <Text class="font-bold">
      Page <PageNumber /> of <TotalPages /></Text>
    <PageBreak />
    <Text class="font-bold">
      Page <PageNumber /> of <TotalPages /></Text>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[200, 120]" class="p-6">
        <ink-text class="font-bold">
          Page <ink-page-number /> of <ink-total-pages /></ink-text>
        <ink-page-break />
        <ink-text class="font-bold">
          Page <ink-page-number /> of <ink-total-pages /></ink-text>
      </ink-page>
    </ink-document>
  `,
})
export class Example {}
Page 1 of the PDF this example renders.Page 2 of the PDF this example renders.

It takes no props.

PageBreak

Starts a new page when content follows it, at any depth of the body. An error inside a flex-row, grid, wrapping or reversed View and inside an absolutely positioned, rotated or transformed element.

import { Document, Page, PageBreak, Text } from '@inkoxide/react';

export default function Example() {
  return (
    <Document>
      <Page size={[200, 120]} className="p-6">
        <Text className="font-bold">Chapter 1</Text>
        <Text className="text-gray-500">Ends here.</Text>
        <PageBreak />
        <Text className="font-bold">Chapter 2</Text>
        <Text className="text-gray-500">Starts on a new page.</Text>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Document, Page, PageBreak, Text } from '@inkoxide/vue';
</script>

<template>
  <Document>
    <Page :size="[200, 120]" class="p-6">
      <Text class="font-bold">Chapter 1</Text>
      <Text class="text-gray-500">Ends here.</Text>
      <PageBreak />
      <Text class="font-bold">Chapter 2</Text>
      <Text class="text-gray-500">Starts on a new page.</Text>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Document, Page, PageBreak, Text } from '@inkoxide/svelte';
</script>

<Document>
  <Page size={[200, 120]} class="p-6">
    <Text class="font-bold">Chapter 1</Text>
    <Text class="text-gray-500">Ends here.</Text>
    <PageBreak />
    <Text class="font-bold">Chapter 2</Text>
    <Text class="text-gray-500">Starts on a new page.</Text>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[200, 120]" class="p-6">
        <ink-text class="font-bold">Chapter 1</ink-text>
        <ink-text class="text-gray-500">Ends here.</ink-text>
        <ink-page-break />
        <ink-text class="font-bold">Chapter 2</ink-text>
        <ink-text class="text-gray-500">Starts on a new page.</ink-text>
      </ink-page>
    </ink-document>
  `,
})
export class Example {}
Page 1 of the PDF this example renders.Page 2 of the PDF this example renders.
PropTypeDescription
idstring

usePage

The page number and page count, inside the output of a render prop (or a component it renders). Elsewhere the page is not known yet: content is laid out once for the whole document.

import { Document, Footer, Page, PageBreak, Text, usePage, View } from '@inkoxide/react';

function Folio() {
  const { pageNumber, totalPages } = usePage();
  return <Text>{pageNumber === totalPages ? 'Last page' : `Page ${pageNumber}, continued`}</Text>;
}

export default function Example() {
  return (
    <Document>
      <Page size={[200, 120]} margin={{ top: 24, right: 24, bottom: 44, left: 24 }}>
        <Text className="font-bold">The quarter in review</Text>
        <PageBreak />
        <Text className="font-bold">What comes next</Text>
        <Footer className="border-t border-gray-200 pt-1.5 text-xs text-gray-500">
          <View render={() => <Folio />} />
        </Footer>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Document, Footer, Page, PageBreak, Text, usePage, View } from '@inkoxide/vue';
import { defineComponent, h } from 'vue';

// A component inside the render slot, where usePage() gives the page it is drawn on.
const Folio = defineComponent(() => {
  const { pageNumber, totalPages } = usePage();
  return () => h(Text, null, () => (pageNumber === totalPages ? 'Last page' : `Page ${pageNumber}, continued`));
});
</script>

<template>
  <Document>
    <Page :size="[200, 120]" :margin="{ top: 24, right: 24, bottom: 44, left: 24 }">
      <Text class="font-bold">The quarter in review</Text>
      <PageBreak />
      <Text class="font-bold">What comes next</Text>
      <Footer class="border-t border-gray-200 pt-1.5 text-xs text-gray-500">
        <View>
          <template #render><Folio /></template>
        </View>
      </Footer>
    </Page>
  </Document>
</template>
<!-- Folio.svelte: a component inside the render snippet, where usePage() gives the page. -->
<script lang="ts">
  import { Text, usePage } from '@inkoxide/svelte';

  const { pageNumber, totalPages } = usePage();
</script>

<Text>{pageNumber === totalPages ? 'Last page' : `Page ${pageNumber}, continued`}</Text>

<!-- Example.svelte -->
<script lang="ts">
  import { Document, Footer, Page, PageBreak, Text, View } from '@inkoxide/svelte';

  import Folio from './Folio.svelte';
</script>

<Document>
  <Page size={[200, 120]} margin={{ top: 24, right: 24, bottom: 44, left: 24 }}>
    <Text class="font-bold">The quarter in review</Text>
    <PageBreak />
    <Text class="font-bold">What comes next</Text>
    <Footer class="border-t border-gray-200 pt-1.5 text-xs text-gray-500">
      <View>
        {#snippet render()}<Folio />{/snippet}
      </View>
    </Footer>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { injectPage } from '@inkoxide/angular';

// A component inside the render template, where injectPage() gives the page it is drawn on.
@Component({
  selector: 'app-folio',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `<ink-text>{{ page.pageNumber === page.totalPages ? 'Last page' : 'Page ' + page.pageNumber + ', continued' }}</ink-text>`,
})
export class Folio {
  readonly page = injectPage();
}

@Component({
  selector: 'app-example',
  imports: [Folio],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[200, 120]" [margin]="{ top: 24, right: 24, bottom: 44, left: 24 }">
        <ink-text class="font-bold">The quarter in review</ink-text>
        <ink-page-break />
        <ink-text class="font-bold">What comes next</ink-text>
        <ink-footer class="border-t border-gray-200 pt-1.5 text-xs text-gray-500">
          <ink-view [render]="folio" />
          <ng-template #folio><app-folio /></ng-template>
        </ink-footer>
      </ink-page>
    </ink-document>
  `,
})
export class Example {}
Page 1 of the PDF this example renders.Page 2 of the PDF this example renders.

It takes no arguments.

It returns:

FieldTypeDescription
pageNumbernumberPhysical page number, from 1.
totalPagesnumberPages in the document.

Synced from components/page.md in the inkoxide repository.