Skip to content

lucas-aragno/react-pdf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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:standalone
  # or
npm run example:standalone

# Open example doc
open examples/standalone/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

Releases

No releases published

Packages

No packages published