@formepdf/react.
Svelte users: every component below is also exported from@formepdf/sveltewith identical props. Swap the import path and the JSX examples work as.sveltemarkup unchanged. See the Svelte guide for setup.
Styling
Styles are plain objects passed to thestyle prop. You can write them inline or extract them with StyleSheet.create() for TypeScript autocomplete:
StyleSheet.create() is an identity function. It returns the same object you pass in. Its purpose is to provide autocomplete and type checking on style properties.
Document
Root container for every Forme document. All other components must be descendants of<Document>.
Props
Example
<Document>. If no <Page> children are provided, content uses the default page configuration (Letter size, 54pt margins).
Page
Defines a page boundary with explicit size and margin configuration. Content inside each<Page> is laid out independently.
Props
Example
View
A flex container, analogous to an HTML<div>. Defaults to column layout.
Props
Example
flexDirection, justifyContent, alignItems, flexWrap, gap, flexGrow, flexShrink) are supported. Set position: 'absolute' in the style to position a View relative to its parent’s content box.
Text
Renders text content with font properties, colors, and alignment.Props
Example
{{pageNumber}} and {{totalPages}} placeholders for dynamic page numbering. Nested <Text> elements share the same line and can have different styles, which is useful for inline formatting like bold words, colored spans, or strikethrough pricing.
Image
Embeds a JPEG or PNG image. Aspect ratio is preserved when only one dimension is specified.Props
Example
width is provided, height is calculated from the image’s aspect ratio (and vice versa). Both JPEG and PNG formats are supported, including PNG transparency.
Table
Table container with column definitions. Children should be<Row> elements.
Props
Column width types
Example
header) are repeated at the top of each continuation page.
Row
A table row. Must be a direct child of<Table>.
Props
Example
Cell
A table cell inside a<Row>.
Props
Example
Svg
Renders inline SVG graphics. Supports basic SVG elements:rect, circle, ellipse, line, polyline, polygon, and path. Elements support opacity, fill-opacity, and stroke-opacity attributes with proper inheritance through <g> groups.
Props
Provide either
content (a raw SVG string) or JSX children — not both. If both are provided, content takes priority.
Example — content string
Example — JSX children
strokeWidth are converted to their kebab-case SVG equivalents (stroke-width).
SVG content is rendered directly into the PDF using native PDF drawing operations, not rasterized. This produces crisp vector output at any zoom level.
QrCode
Renders a QR code from a data string. Output is vector-based (not a raster image), so it stays crisp at any zoom level.Props
Example
Barcode
Renders a 1D barcode from a data string. Output is vector-based (filled rectangles), crisp at any zoom level.Props
Example
Fixed
An element that repeats on every page as a header or footer. Reduces the available content area on each page.Props
Example
{{pageNumber}} and {{totalPages}} placeholders inside Fixed elements for automatic page numbering.
PageBreak
Forces content after this element to start on a new page.Props
None.Example
Canvas
Renders arbitrary vector graphics via adraw callback. The callback receives a recording context with a Canvas-like API. All drawing commands are serialized and rendered as native PDF vector operations.
Props
CanvasContext methods
moveTo(x, y), lineTo(x, y), line(x1, y1, x2, y2), bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y), quadraticCurveTo(cpx, cpy, x, y), arc(cx, cy, r, startAngle, endAngle, counterclockwise?), circle(cx, cy, r), rect(x, y, w, h), ellipse(cx, cy, rx, ry), closePath(), stroke(), fill(), setFillColor(r, g, b), setStrokeColor(r, g, b), setLineWidth(w), setLineCap(cap), setLineJoin(join), save(), restore().
line(x1, y1, x2, y2) is a convenience that emits moveTo + lineTo + stroke in one call.
Colors use 0-255 RGB values (like HTML Canvas). Content is clipped to the canvas bounds (matching HTML Canvas behavior).