New react-pdf 2.0 was released. Read about the announcement

React-pdf

Edit

Node API

renderToFile

Helper function to render a PDF into a file.

Usage

const MyDocument = () => (
  <Document>
    <Page>
      <Text>React-pdf</Text>
    </Page>
  </Document>
);

await renderToFile(<MyDocument />, `${__dirname}/my-doc.pdf`);

Arguments

Prop nameDescriptionDefault
documentDocument's root element tp be renderedundefined
pathFile system path where the document will be createdundefined
callbackFunction to be called after renderig is finishedundefined

renderToString

Helper function to render a PDF into a string.

Usage

const MyDocument = () => (
  <Document>
    <Page>
      <Text>React-pdf</Text>
    </Page>
  </Document>
);

const value = await renderToString(<MyDocument />);

Arguments

Prop nameDescriptionDefault
documentDocument's root element tp be renderedundefined

Returns

String representation of PDF document

renderToStream

Helper function to render a PDF into a Node Stream.

Usage

const MyDocument = () => (
  <Document>
    <Page>
      <Text>React-pdf</Text>
    </Page>
  </Document>
);

const stream = await renderToStream(<MyDocument />);

Arguments

Prop nameDescriptionDefault
documentDocument's root element to be renderedundefined

Returns

PDF document Stream

← Fonts