### Start Development Server Source: https://github.com/diegomura/react-pdf/blob/master/packages/examples/vite/README.md Starts the development server. Navigate to the vite example directory before running. ```bash cd packages/examples/vite yarn dev ``` -------------------------------- ### Installation Source: https://github.com/diegomura/react-pdf/blob/master/packages/math/README.md Install the @react-pdf/math package and its peer dependencies. ```APIDOC ## Installation ### npm ```bash npm install @react-pdf/math ``` ### yarn ```bash yarn add @react-pdf/math ``` ### Peer Dependencies ```bash npm install @react-pdf/renderer react ``` ``` -------------------------------- ### Install @react-pdf/math Source: https://github.com/diegomura/react-pdf/blob/master/packages/math/README.md Commands to install the package and its required peer dependencies. ```bash npm install @react-pdf/math # or yarn add @react-pdf/math ``` ```bash npm install @react-pdf/renderer react ``` -------------------------------- ### Installation Source: https://github.com/diegomura/react-pdf/blob/master/packages/mermaid/README.md Install the @react-pdf/mermaid package using yarn. ```APIDOC ## Installation ```bash yarn add @react-pdf/mermaid ``` ``` -------------------------------- ### Install Dependencies and Build Project Source: https://github.com/diegomura/react-pdf/blob/master/packages/examples/vite/README.md Installs project dependencies and builds the project. Run these commands from the repository root. ```bash yarn install yarn build ``` -------------------------------- ### Install @react-pdf/textkit Source: https://github.com/diegomura/react-pdf/blob/master/packages/textkit/README.md Use yarn to add the package to your project. ```bash yarn add @react-pdf/textkit ``` -------------------------------- ### Install @react-pdf/stylesheet Source: https://github.com/diegomura/react-pdf/blob/master/packages/stylesheet/README.md The installation command for the stylesheet library using yarn. ```bash yarn add @react-pdf/stylesheet ``` -------------------------------- ### Install @react-pdf/image Source: https://github.com/diegomura/react-pdf/blob/master/packages/image/README.md The installation command for the library using the yarn package manager. ```bash yarn add @react-pdf/image ``` -------------------------------- ### Regenerate PDFs Source: https://github.com/diegomura/react-pdf/blob/master/packages/examples/vite/README.md Regenerates all PDFs for the examples. Ensure you are in the vite example directory. ```bash cd packages/examples/vite node generate-pdfs.mjs ``` -------------------------------- ### Install @react-pdf/svg Source: https://github.com/diegomura/react-pdf/blob/master/packages/svg/README.md Use npm or yarn to add the package to your project. ```bash npm install @react-pdf/svg # or yarn add @react-pdf/svg ``` -------------------------------- ### Install @react-pdf/fns Source: https://github.com/diegomura/react-pdf/blob/master/packages/fns/README.md Installation command for adding the library to a project using yarn. ```bash yarn add @react-pdf/fns ``` -------------------------------- ### Start the Next.js development server Source: https://github.com/diegomura/react-pdf/blob/master/packages/examples/next-14/README.md Use these commands to launch the local development environment. Choose the command corresponding to your preferred package manager. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Install @react-pdf/mermaid Source: https://github.com/diegomura/react-pdf/blob/master/packages/mermaid/README.md Use yarn to add the package to your project dependencies. ```bash yarn add @react-pdf/mermaid ``` -------------------------------- ### Using Themes Source: https://github.com/diegomura/react-pdf/blob/master/packages/mermaid/README.md Example of how to apply a built-in theme to the Mermaid diagram. ```APIDOC ## Themes The following built-in themes are available via the `theme` prop: - `tokyo-night`, `tokyo-night-storm`, `tokyo-night-light` - `catppuccin-mocha`, `catppuccin-latte` - `nord`, `nord-light` - `dracula` - `github-dark`, `github-light` - `solarized-dark`, `solarized-light` - `one-dark` - `zinc-dark`, `zinc-light` ```jsx {`graph LR A --> B --> C`} ``` ``` -------------------------------- ### Install @react-pdf/primitives Source: https://github.com/diegomura/react-pdf/blob/master/packages/primitives/README.md Command to install the primitives package via the yarn package manager. ```bash yarn add @react-pdf/primitives ``` -------------------------------- ### Configure Math Display Modes Source: https://github.com/diegomura/react-pdf/blob/master/packages/math/README.md Examples showing the difference between default display mode and inline mode. ```tsx {"\int_0^\infty e^{-x^2} dx = \sqrt{\pi}"} ``` ```tsx The equation {"E = mc^2"} is famous. ``` -------------------------------- ### Install React PDF Renderer Source: https://github.com/diegomura/react-pdf/blob/master/packages/renderer/README.md Use this command to add the @react-pdf/renderer package to your project. ```sh yarn add @react-pdf/renderer ``` -------------------------------- ### Install @react-pdf/types Source: https://github.com/diegomura/react-pdf/blob/master/packages/types/README.md Use this command to add the TypeScript definitions to your project via yarn. ```sh yarn add @react-pdf/types ``` -------------------------------- ### Render Matrices Source: https://github.com/diegomura/react-pdf/blob/master/packages/math/README.md Example of rendering a matrix using LaTeX. ```tsx {"\begin{pmatrix} a & b \\ c & d \end{pmatrix}"} ``` -------------------------------- ### Render Fractions and Roots Source: https://github.com/diegomura/react-pdf/blob/master/packages/math/README.md Example of rendering a fraction with a square root. ```tsx {"\frac{\sqrt{3}}{2}"} ``` -------------------------------- ### Render Limits Source: https://github.com/diegomura/react-pdf/blob/master/packages/math/README.md Example of rendering a limit expression. ```tsx {"\lim_{x \to 0} \frac{\sin x}{x} = 1"} ``` -------------------------------- ### Render Summations and Integrals Source: https://github.com/diegomura/react-pdf/blob/master/packages/math/README.md Examples of complex mathematical notations like summations and integrals. ```tsx {"\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}"} {"\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}"} ``` -------------------------------- ### Install @react-pdf/render Source: https://github.com/diegomura/react-pdf/blob/master/packages/render/README.md This snippet shows the command to add the @react-pdf/render package to your project using Yarn. ```sh yarn add @react-pdf/render ``` -------------------------------- ### Install @react-pdf/font Source: https://github.com/diegomura/react-pdf/blob/master/packages/font/README.md Installs the @react-pdf/font package using Yarn. This is the primary step to include the font management library in your project. ```bash yarn add @react-pdf/font ``` -------------------------------- ### Create a PDF Document Component Source: https://github.com/diegomura/react-pdf/blob/master/packages/renderer/README.md Define your PDF content using React components and StyleSheet for styling. This example shows a basic document with two sections. ```jsx import React from 'react'; import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer'; // Create styles const styles = StyleSheet.create({ page: { flexDirection: 'row', backgroundColor: '#E4E4E4', }, section: { margin: 10, padding: 10, flexGrow: 1, }, }); // Create Document Component const MyDocument = () => ( Section #1 Section #2 ); ``` -------------------------------- ### Render Greek Letters and Operators Source: https://github.com/diegomura/react-pdf/blob/master/packages/math/README.md Example of rendering vector calculus notation. ```tsx {"\nabla \times \vec{E} = -\frac{\partial \vec{B}}{\partial t}"} ``` -------------------------------- ### Rendering to PDF with @react-pdf/render and pdfkit Source: https://github.com/diegomura/react-pdf/blob/master/packages/render/README.md This example shows how to render a document structure to a PDF file using @react-pdf/render in conjunction with pdfkit. It involves creating a PDFDocument instance and piping it to a file stream. ```javascript import fs from 'fs'; import render from '@react-pdf/render'; import pdfkit from '@react-pdf/pdfkit'; const PDFDocument = pdfkit.default; const ctx = new PDFDocument({ autoFirstPage: false }); const doc = {}; // See above render.default(ctx, doc); const stream = fs.createWriteStream('./test.pdf'); ctx.pipe(stream); ``` -------------------------------- ### Convert CSS Units Source: https://github.com/diegomura/react-pdf/blob/master/packages/stylesheet/README.md Examples of how various CSS units are converted to PDF points (pt). ```javascript const style = { width: '2in', height: '50mm', padding: '1cm', margin: '10vh', fontSize: '5vw', gap: '2rem', left: '100px', }; ``` -------------------------------- ### React-PDF Form Components Example Source: https://context7.com/diegomura/react-pdf/llms.txt Demonstrates the usage of various interactive form components including TextInput, Checkbox, Select, and FieldSet. It requires '@react-pdf/renderer' and includes basic styling for layout and appearance. The output is a PDF document with form fields. ```jsx import { Document, Page, View, Text, TextInput, Checkbox, Select, FieldSet, StyleSheet } from '@react-pdf/renderer'; const styles = StyleSheet.create({ page: { padding: 30 }, label: { fontSize: 12, marginBottom: 5 }, input: { width: 200, height: 25, marginBottom: 15, borderWidth: 1, borderColor: '#333', }, checkbox: { width: 15, height: 15, marginRight: 10, }, row: { flexDirection: 'row', alignItems: 'center', marginBottom: 10, }, fieldset: { marginBottom: 20, padding: 15, borderWidth: 1, borderColor: '#ddd', }, }); const FormExample = () => (
Full Name: Email: Phone: Password: Comments:
Subscribe to newsletter I accept the terms and conditions Country: