Is there a way to convert a valid HTML document to PDFmake syntax? I have done all the designing in HTML and CSS. Is there a way to convert that into a valid PDFmake syntax?
Asked
Active
Viewed 5,818 times
1 Answers
2
I had good results using html-to-pdfmake. You can check the demo link to see if your HTML is compatible but you'll still have to convert your CSS manually though.

Matt C
- 61
- 2
-
Unfortunately, html-to-pdfmake relies on the browser's rendering. – Marc Wäckerlin Oct 09 '20 at 07:31
-
Fortunately, it works well with jsDOM, so to convert on NodeJS server, use: ``` import htmlToPdfmake from 'html-to-pdfmake'; import { JSDOM } from 'jsdom'; const pdfmakeJson = htmlToPdfmake(htmlAsString, new JSDOM()); ``` – Marc Wäckerlin Oct 09 '20 at 07:50
-
Somehow, `html-topdfmake` ignores bootstrap classes. Only properties specified in `style` attribute are getting applied. – Kishor Pawar May 20 '21 at 15:08
-
of course it requires css, margin as per pdfmake way, I provided that & it worked :) thanks, made my day – neekheel Sep 15 '22 at 05:22