How to generate PDF in JS?
From experience I will say that it is better to use full-fledged tools for generating PDF than options with automatic conversion of html to pdf. I would recommend pdfkit.orgAnonymous
Of the options proposed by the author, it is definitely puppeteer. At the front, you will start to suffer with cross-browser code, limits (multi-page pdfs will take you by surprise), and quality - at the front, as a rule, html = & gt; raster = & gt; pdf and everything floats when enlarged. puppeteer (via chromium) keeps an honest vector where appropriate. Yes, and html layout will not have to be done for an army of browsers, but only for the chromium of a previously known version.Anonymous
there are many options on the front, on the back the most "accurate" option will be the option with headless chrome, or something like a pupitir, all the rest are quite buggy and do not support normal layout. As mentioned by Semyon Kuznetsov - a simple option - printing in pdf from chrome, in fact, this is almost analogous to headless chrome on the backend, only on the front ... If this is not a commercial product for paid users, then this option is generally out of competition.Anonymous
Do you need massive generation?
That is, to generate for some reason, I can't even imagine why, a hundred pdf. Or is it elementary that some manager would press the download button and receive a PDF file, for example, with statistics?Anonymous
There is also another option (on a clean backend): prepare templates in advance in PDF format with all static data (for example, bank details). When requesting a download, add to the empty fields and give the file. And you don't have to fool around generating PDFs from scratch. appending data to an existing PDF is an easy operation. They did just that on sale.Anonymous
To place the code, please use CodePen or similar tool. Thanks you!