How to use the react-pdf.pdfjs.disableWorker function in react-pdf

To help you get started, we’ve selected a few react-pdf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arinyguedes / safenotes / src / fileManager.js View on Github external
return new Promise(function (resolve, reject) {
            var simpleName = name
            name = FileManager._getFileName(name)
            var metadataFileName = metadataFilePrefix + name
            var fileName = filePrefix + name
            var firstPageFileName = firstPageFilePrefix + name
            var content = FileManager._getFileUrl(arrayBuffer, type)
            pdfjs.disableWorker = true
            pdfjs.getDocument(content).then((pdf) =>
            {
                pdf.getPage(1).then((page) =>
                {
                    var viewport = page.getViewport(0.6)
                    var canvas = document.createElement('canvas')
                    var context = canvas.getContext('2d')
                    canvas.height = viewport.height
                    canvas.width = viewport.width
                    page.render({canvasContext: context, viewport: viewport}).then(() =>
                    {
                        var firstPage = canvas.toDataURL('image/jpeg')
                        var now = (new Date()).getTime()
                        var metadata = {
                            name: simpleName,
                            size: size,

react-pdf

Display PDFs in your React app as easily as if they were images.

MIT
Latest version published 1 day ago

Package Health Score

79 / 100
Full package analysis