htmlToPdf static method

dynamic htmlToPdf(
  1. String html, {
  2. Function? callback,
  3. Map<String, dynamic> pageSettings = const {},
})

Implementation

static htmlToPdf(String html,{Function? callback,Map<String,dynamic >pageSettings=const {}})async{
  _debug("Generating pdf from html");
  html=html.replaceAll("</body>", '<script>console.log("report generated");</script></body>');
  Page page=await browser.newPage();
  _debug("Created page");
  page.onConsole.listen((event) async {
    if(event.text!=null) {
      _debug(event.text);
      if(event.text=="report generated"){

      }
    }
  });
  _debug("Setting Html");
  await page.setContent(html,wait: Until.networkIdle,);
  _debug("Html Set");
  await pagePdf(page,callback: callback,pageSettings: pageSettings);
  page.close();
}