Django: How i can delete the white space between the background image and the origin page also Page number appear (Page undefined of undefined)

123 views Asked by At

Am still learning on Django and wkhtml2pdf using and I need some help please, I have searched and try much solutions but they don't work with me, I want to set a background image and page number in the footer(I Have use wkhtml2pdf library):

Here it's the code

<!doctype html>
<html lang="en">
  <head>
    <style type="text/css">
      body{
      background-image: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD/...');
      margin:0px;
      background-size: cover;
      background-position: left top;
      padding-top:0px;
      height: 1100px; 
      width: 900px;     
      } 
      #divb
      {
        font-size: 12px; 
        font-family: Arial;
      }
      div.footer {
          display: block; text-align: center;
          position: running(footer);
      @page { 
          @bottom-center { content: element(footer) }
           }
      }
   </style>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
 </head>
 <body style="border:0; margin: 0;">
   <div id="divb">
      <p><strong>Materials :</strong> {{ materiel }}</p> 
.........(the rest of calling the data)
   </div>
   <div class='footer'>
      Page <span id='page'></span> of 
      <span id='topage'></span>   
      <script> 
        var vars={};
        var x=window.location.search.substring(1).split('&');
        for (var i in x) {
          var z=x[i].split('=',2);
          vars[z[0]] = unescape(z[1]);
        }
        document.getElementById('page').innerHTML = vars.page; 
        document.getElementById('topage').innerHTML = vars.topage; 
      </script> 
  </div>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
  <script>
      window.load = function() {
        window.status = 'render-pdf';
      };
  </script>
 </body>
</html>

and here it's the result :

the was a white space between the background image and the origin page , also the number of page appear to me (Page undefined of undefined), How i can adjust the background-image correctly to filled out all the page without white space , also what' wrong with page number in the footer.

see the screenshoot please.

enter image description here

.Thanks In Advance for everyone here.

0

There are 0 answers