Onedoc makes it easy to generate PDFs using modern web technologies.
1 | <Invoice |
2 | company="Acme Inc." |
3 | amount="$12.99" |
4 | date="2024-02-08" |
5 | paymentMethod="mastercard" |
6 | cardDigits={0911} /> |
Create your first document in minutes. Our simple developer APIs allow a seamless integration with your existing stack.
1 | import { Onedoc } from '@onedoc/client'; |
2 | import fs from 'fs'; |
3 | import { renderToString } from 'react-dom/server'; |
4 | |
5 | import { PDFTemplate } from './components/PDFTemplate'; |
6 | |
7 | const onedoc = new Onedoc(process.env.ONEDOC_API_KEY); |
8 | |
9 | const { file, link, info, error } = await onedoc.render({ |
10 | html: renderToString(<PDFTemplate title="My First PDF" />), |
11 | }); |
12 | |
13 | fs.writeFileSync('invoice.pdf', file); |
Craft custom documents with your favorite frontend tools like React and Vue.
Instantly generate dynamic documents based on real-time data.
Secure your documents with trusted digital signatures.
We handle document delivery and lifecycle management for you.
Track views and downloads for insights into document engagement.
Easily integrate with tools like Google Drive and DocuSign.
Design templates with your favorite frontend technologies.
React, Vue, Tailwind, you name it.
1 | |
2 | import React from "react"; |
3 | import { InvoiceTemplate } from "./components/invoice"; |
4 | import { Onedoc } from "@onedoc/client"; |
5 | import { readFileSync, writeFileSync } from "fs"; |
6 | import { renderToString } from "react-dom/server"; |
7 | import postcss from "postcss"; |
8 | import tailwindcss from "tailwindcss"; |
9 | import postcssColorFunctionalNotation from "postcss-color-functional-notation"; |
10 | |
11 | const ONEDOC_API_KEY = "####-####-####-####” // replace with your api key |
12 | |
13 | const onedoc = new Onedoc(ONEDOC_API_KEY); |
14 | |
15 | const data = {}; // load data for template |
16 | |
17 | (async () => { |
18 | |
19 | const html = renderToString(<InvoiceTemplate props={data} />) |
20 | const css = await postcss([ |
21 | tailwindcss({ |
22 | content: [{ raw: html, extension: "html" }], |
23 | }), |
24 | postcssColorFunctionalNotation,]) |
25 | .process(`@tailwind base;@tailwind components;@tailwind utilities;`, { |
26 | from: undefined, |
27 | }); // loads compiled tailwind styles |
28 | |
29 | let doc = { |
30 | html: html, |
31 | title: "Hello", |
32 | test: true, // if true, produce a PDF in test mode with a Onedoc's watermark |
33 | save: true, // if true, host the document and provide a download link in the console and your Onedoc's dashboard |
34 | expiresIn: 30, // the number of day you want to host your document |
35 | assets: [ |
36 | { |
37 | path: "./style.css", |
38 | content: css.toString(), |
39 | }, |
40 | ], |
41 | }; |
42 | |
43 | const { file, link, error, info } = await onedoc.render(doc); |
44 | |
45 | if (error) { |
46 | throw error; |
47 | } |
48 | |
49 | console.log(link); |
50 | })(); |
51 |
We build templates so you don't have to.
We have worked with some of the best teams and companies in the world.
Here is what they have to say.
Join our public beta and start generating, hosting and tracking documents this afternoon.
Use Onedoc now, it's free