Server pdfmake font directory in meteor application

I am trying to create and save a pdf file on a server. I used meteorhacks: npm is packaged and pdfmake installed on the server side.

My code is in a subdirectory under the server directory. I am only using an example to make sure I can generate a basic pdf.

 var fonts = {
                Roboto: {
                    normal: 'fonts/Roboto-Regular.ttf',
                    bold: 'fonts/Roboto-Medium.ttf',
                    italics: 'fonts/Roboto-Italic.ttf',
                    bolditalics: 'fonts/Roboto-Italic.ttf'
                }
            };
            var PdfPrinter = Meteor.npmRequire('pdfmake/src/printer');
            var printer = new PdfPrinter( fonts );

            var dd = {
                content: [
                    'First paragraph',
                    'Another paragraph'
                ]
            };
            var pdfDoc = printer.createPdfKitDocument(dd);
            pdfDoc.pipe(fs.createWriteStream('basics.pdf')).on('finish',function(){
                //success
            });
            pdfDoc.end();

      

I get

 Error: ENOENT, no such file or directory 'fonts/Roboto-Regular.ttf'

      

I'm a bit puzzled as to where my font directory should be.

I tried to debug the pdfmake library and got lost. Placed the font directory in different locations with no luck.

Any ideas?

+1


source to share


1 answer


download roboto font and create fonts folder in root directory and paste these dependent files.



0


source







All Articles