0
I’m using the pdfMake library for generating billets, and it was working fine, until I went to follow some examples of the documentation on website and returned me an error, I searched the solution in several issues opened on Github and other sites but none helped me, remembering that I am making the generation of PDF’s on my server Nodejs.
/* O método abaixo é outro jeito de conseguir gerar o documento, e
esse método achei nos exemplos no site do pdfMake, e esse método
funciona, porém não consigo atribuir as funções de 'download()',
'open' e 'print()'*/
pdfMake = printer.createPdfKitDocument(conteudoPDF); //Método funcional
/* O código abaixo é o exemplo que está na documentação e que está
retornando o erro "TypeError: pdfMake.createPdf is not a function" */
pdfMake.createPdf(conteudoPDF).open(); // Método não funcional
pdfMake.pipe(fs.createWriteStream('../pdfs/testeJson.pdf'));
pdfMake.end();
Unfortunately returns the same error, I went to look at the documentation and Github of the developer who created pdfMake and it does not commit any of his projects from github since May 18 last year, that is, he abandoned the library and still made it available for use and with bugs, but it is very easy to use and actually creates pdfs through that other method I showed in my code snippet, but does not have the options to print, open and download, I’ll open a new question to see if you can do these 3 options manually, no library use, thank you so much for the help.
– LeonardoEbert
There is also a cool alternative which is jsPDF, but it only saves the pdf page. You can use it through CDN: <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.debug.js"></script> to instantiate the jsPDF object. The following is documentation on github: https://github.com/MrRio/jsPDF
– Lucas Souza
Already researched about it, really is an interesting tool, but I’m taking data from Mongodb and putting straight into the PDF, I believe that in this case it would not meet my need. Thanks again for your willingness to help, vlw msm.
– LeonardoEbert