Pdfmake: SVGs not working

Created on 30 Jul 2019  路  3Comments  路  Source: bpampuch/pdfmake

Hi,

Using pdfmake@^0.1.58, with svg-to-pdfkit installed (as per documentation), I'm getting this:

Uncaught Error: Please install svg-to-pdfkit to enable svg nodes
    at getSvgToPDF (pdfmake.js:18787)
    at renderSVG (pdfmake.js:19365)
    at renderPages (pdfmake.js:19143)
    at PdfPrinter.createPdfKitDocument (pdfmake.js:18908)
    at Document._createDoc (pdfmake.js:18310)
    at Document.getBuffer (pdfmake.js:18472)
    at Document.getBlob (pdfmake.js:18462)
    at pdf.js:215

I'm generating the PDFs on the client (in browser), with the following import:
import pdfMake from 'pdfmake/build/pdfmake';
Looking inside that file, I see the following built code:

var getSvgToPDF = function () {
    try {
        // optional dependency to support svg nodes
        return __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module 'svg-to-pdfkit'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
    } catch (e) {
        throw new Error('Please install svg-to-pdfkit to enable svg nodes');
    }
};

Doesn't the lib need a rebuild?

Most helpful comment

Indeed a new build is needed. For now you can go with your terminal to the designated node_modules/pdfmake folder and run:

npm install
gulp build

All 3 comments

Indeed a new build is needed. For now you can go with your terminal to the designated node_modules/pdfmake folder and run:

npm install
gulp build

Hello,

Wondering when the new build to support svg-to-pdfkit will be created?

I've put up a simple fork with the rebuild after installing svg-to-pdfkit in it here: https://github.com/jkoudys/pdfmake

install "pdfmake": "[email protected]:jkoudys/pdfmake.git", to get 1.58 w/ svg support on the client side.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmatesic picture dmatesic  路  3Comments

svenyonson picture svenyonson  路  3Comments

MathLavallee picture MathLavallee  路  3Comments

jokris1 picture jokris1  路  3Comments

qgliu picture qgliu  路  3Comments