0

I have an generated a html page as a string which is stored in a variable (let's call it var htmlPage) I want to convert it to a pdf which I can later download

var htmlPage = '<!DOCTYPE html>\n'+
'<html lang="en" dir="ltr">\n'+
  '<head>\n'+
    '<meta charset="utf-8">\n'+
    '<title></title>\n'+

    '<style>\n'+
    '.hyperlink{\n'+
      'color: blue;\n'+
      'cursor: pointer;\n'+
    '}\n'+
   '</style>\n'+
  '</head>\n'+
  '<body>\n'+
    '<h1>Hello world!</h1>\n'+
  '</body>\n'+
'</html>';

1 Answers1

0

The way you want it is actually not possible. Alternate way is to write it in a div and hide the div, once the user clicks print, display the div and hide everything else before printing. Doing so the div you want to print will get printed