Custom Static Javascript HTML to PDF

I am trying to make invoices for my static website. I am trying to convert an HTML page to a PDF page. I been doing static websites rather than Node.JS because I can’t host Node.JS websites. What have I done wrong?

What have I tried


<!DOCTYPE html>
      body {
        padding: 0;
        margin: 0;
      iframe {
        width: 100%;
        height: 100%;
        border: 0;
      srcdoc="<p>Hello world!</p>"


I have gotten the "Hello World" to display but it was just in a html page rather then a PDF page.

20 thoughts on “Custom Static Javascript HTML to PDF”

  1. It would better to create a small PHP script to handle this process.
    Give a look at: spipu/html2pdf

    A possible solution is to add a print button, something like this:

    onclick="window.print();return false;

    Then add this to the <head> tag:

    type="text/css" media="print"

Leave a Comment