Skip to content

Soulpoor/react-pdf

 
 

Repository files navigation

react-pdf

React renderer for creating PDF files

This project was created to show some concepts on a talk, and it's purely experimental. You can check out the slides of the talk here

Now using the new React Fiber API!

How it works

ReactPDF mounter is called ReactPDF and has a render method that recieves a React Element and a path where the PDF file will be generated.

import React from 'react';
import ReactPDF from '../';
import lorem from './lorem';

let doc =
  <document title="Lorem Ipsum" author="@diegomura" otherData="Something else">
    <page margin={50}>
      <image src="examples/images/react.png" x={200} y={300} width={200} />
      <text align="center" underline>
        ~ Lorem ipsum ~
      </text>
      <text columns={3} columnGap={15} align='justify'>
        {lorem}
      </text>
    </page>
  </document>

ReactPDF.render(doc, './examples/example.pdf');

Check out the result

Demo

# Clone the repo
git clone https://github.com/diegomura/react-pdf
cd react-pdf

# Install dependencies
yarn install
  # or
npm install

# Run example script
yarn example
  # or
npm run example

# Open example doc
open examples/example.pdf

Check out for the example.pdf file created on the root of the project

About

Create PDF files using React

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%