Search code examples
javascriptpdfmake

TypeError: Cannot read property 'Roboto-Regular.ttf' of undefined


Trying to build a PDF using the JS API PdfMake :

<script type="text/javascript" src="/app/js/vfs_fonts.js"></script>
<script type="text/javascript" src="/app/js/pdfmake.min.js"></script>

Then according to this Helloworld , i run :

 var docDef={ content: 'This is an sample PDF printed with pdfMake' }
 pdfMake.createPdf(docDef).download('optionalName.pdf');

i've got this error :

Uncaught TypeError: Cannot read property 'Roboto-Regular.ttf' of undefined

Does Roboto-Regular.ttf File is required ?

And Where to put it ,if so ?


Solution

  • I solved the problem importing pdfmake before vfs_fonts.

    <script type="text/javascript" src="/app/js/pdfmake.min.js"></script>
    <script type="text/javascript" src="/app/js/vfs_fonts.js"></script>