Pdfmake: Streamline api between browser and node.js

Created on 12 Dec 2014  路  14Comments  路  Source: bpampuch/pdfmake

Currently it looks like pdfmake is exposing different apis in the browser and in node.js. Imho they should look the same...

If you're using a tool like browserify or webpack the package.json main field will be used and thus the node api, which can be misleading.

feature request

Most helpful comment

+1

This is pretty important. I can't get this to run in webpack at all.

All 14 comments

Could you make this a pull request? ;-)

+1

This is pretty important. I can't get this to run in webpack at all.

@volkanunsal I'm not using this module, so unfortunately it's up to you.

+1

How to use this in the browser with webpack?

If you webpack and pdfmake lib from the build folder link used it would have to go is white following.

require("script!**./Path to the lib pdfmake***"); 

Then you can run without what to initialize the following command immediately:

pdfMake.createPdf(docDefinition);

If you NPM USER it's even easier.
npm install pdfmake

var PdfPrinter = require('pdfmake'); 
var fonts = { Roboto: { normal: 'citycontrasts.ttf' } }; 
var printer = new PdfPrinter(fonts); 
var pdfDoc = printer.createPdfKitDocument(docDefinition); 

So it should also run without Problehme in Webpack.

@circy I can get none of your examples to work with NPM + WebPack. I keep getting:

pdfmake.createPdf is not a function

as I described here. Did you test it? What could be wrong in my setup?

Anybody here that got pdfmake + webpack + npm working? After 2 days of trying I'm about to give up and go with pdfkit instead, but that would really be a step back for me.

@volkanunsal @Agamennon Did either of you ever get this to work in the browser using WebPack? See #522 for my struggle to get this working.

@circy How can I do that in es6?

@rdpascua Did you get it work?

Anybody got it to work? Struggling with the same.

pdfmake.createPdf is not a function

I followed https://github.com/bpampuch/pdfmake/issues/939#issuecomment-318846576 and it is working.

Unify pdfmake interface for node and browser by commit https://github.com/bpampuch/pdfmake/commit/9b22d8ab20f41b9d7c8a31db9f13617a3082accc in master.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

einfallstoll picture einfallstoll  路  3Comments

qgliu picture qgliu  路  3Comments

m-brudi picture m-brudi  路  3Comments

kamilkp picture kamilkp  路  3Comments

kumarandena picture kumarandena  路  3Comments