Skip to content

Render prop component that turns PDF files into image data URLs

Notifications You must be signed in to change notification settings

cordobadigitalmedia/react-pdf-to-image

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-pdf-to-image

A a render prop component wrapper around pdf.js that asynchronously converts PDF files into data URLs in the browser.

Example Usage

import React from 'react';
import {PDFtoIMG} from 'react-pdf-to-image';
import file from './pdf-sample.pdf';

const App = () =>
    <div>
        <PDFtoIMG file={file}>
            {({pages}) => {
                if (!pages.length) return 'Loading...';
                return pages.map((page, index)=>
                    <img key={index} src={page}/>
                );
            }}
        </PDFtoIMG>
    </div>

export default App;

Issues

  • Relies on the pdf.js distribution from Mozilla which uses a web worker. Currently in order to get this working the pdfjs-dist/build/pdf.worker.js file must be included in your projects build foldler and does not work in Webpack while running in development mode.

  • Not optimized for loading very large multi-page PDFs and works best when used to convert simple single page documents to Image URLs

  • POC atm so there's no tests or error handling.

About

Render prop component that turns PDF files into image data URLs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%