Mike Kokadii
Mike Kokadii

Reputation: 523

Rendering on the fly two or more PDF files

I need to create two buttons which downloads pdf I created with react-pdf. I try it like this:

const docs = [<Doc1 />, <Doc2 />]
const Buttons = () => docs.map(doc =>
    <PDFDownloadLink document={doc} >
    {
        ({loading}) => (<Button loading={loading} />)
    }
    </PDFDownloadLink>
)

And when i try to render it, I get an error

Cannot read property 'hasGlyphForCodePoint' of null

I use custom fonts but there is no other way to get Cyrilic in react-pdf. When i remove custom fonts, both of documents renders successfully, but there are no Cyrilic. What should i do?

Upvotes: 1

Views: 2252

Answers (1)

johjoh
johjoh

Reputation: 465

The issue and some workarounds are described here: https://github.com/diegomura/react-pdf/issues/310

I ended up using this solution: https://gist.github.com/JacobFischer/aecbd871cb2aae46993236f65797da5c ... which moves the PDF generation to the click event.

In general it seems to be a problem of async/simultaneous generation of multiple PDFs.

Upvotes: 2

Related Questions