htmlcsshtml2pdf

Display background image HTML2PDF


I would like to convert html file into pdf format using online tools or html2pdf library. But it converts all page but not background image.

<STYLE type="text/css">    
    body {margin-top: 0px;margin-left: 0px;
        background-image: url(http://IP/check/form/image.jpg);
     }
</style>
<html>
<body>
    <div>
        <h1>Hello world!</h1>
        <p><a href="http://www.w3schools.com">Visit W3Schools.com!</a></p>
    </div>
</body>
</html>

Solution

  • Changing body tag background to div tag background URL solved the issue.

      <STYLE type="text/css">    
        #divid{margin-top: 0px;margin-left: 0px;
            background-image: url(http://****.jpg);
         }
    </style>
    <html>
    <body>
        <div id="divid">
            <h1>Hello world!</h1>
            <p><a href="http://www.w3schools.com">Visit W3Schools.com!</a></p>
        </div>
    </body>
    </html>