Skip to content

ercpereda/react-pdf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 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.

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

git clone https://github.com/diegomura/react-pdf
cd react-pdf
npm install

# run example script
npm run example

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

Thanks

  • @iamdustan for the explanation of how to build a renderer

About

Create PDF files using React

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%