This is the html string and i want to print it in pdfmake
let html_string = "<html><head></head><body><p>HI</p></body></html>";
//something like this
{ text: html_string,
pageBreak: 'after',
},
it should print as a html content in a part of pdfmake: how to print string containing html as it is in pdf .
Use a html parser to get the html content you want. https://www.npmjs.com/package/node-html-parser
After that, i would write an object build function to get the correct html tag content you're looking for.
import { parse } from 'node-html-parser';
const root = parse('<ul id="list"><li>Hello World</li></ul>');
var htmlBody = root.querySelector('#list');
function getContentBuilder (htmlBody ) {
var record = {}
//Locate htmlBody childnode that you want and insert to record
return record;
}
//something like this
{ text: getContentBuilder(htmlBody) ,
pageBreak: 'after',
},