0

Hey i am facing a probleme with exporting pdf make functionality:

var pdfMake = require('pdfmake/build/pdfmake.js');
var pdfFonts = require('pdfmake/build/vfs_fonts.js');
pdfMake.vfs = pdfFonts.pdfMake.vfs;

export default pdfMake;

import the file with a custom webpack alias as pdfMakeGenerator:

const pdfMake = require('pdfMakeGenerator');
pdfMake.createPdf(docDefinition).download("test");

this gives me an error like:

pdfMake.createPdf is not a function
Aziz.G
  • 3,599
  • 2
  • 17
  • 35
  • 2
    Possible duplicate of https://stackoverflow.com/questions/35494376/pdfmake-pdfmake-createpdf-is-not-a-function – Grandtour Apr 28 '20 at 20:30
  • no it's not, i think it's export problem but i am not sure btw it's for client side – Aziz.G Apr 28 '20 at 22:00

1 Answers1

0

My solution was doing it this way:

var pdf = require('pdfmake/build/pdfmake.js');
var pdfFonts = require('pdfmake/build/vfs_fonts.js');
pdf.vfs = pdfFonts.pdfMake.vfs;

export const pdfMake = pdf;

then

const { pdfMake } = require('pdfMakeGenerator');
Aziz.G
  • 3,599
  • 2
  • 17
  • 35