How to add page border while generating html to pdf

5.9k Views Asked by At

How to add page border for all generated pdf pages from HTML to pdf using wkhtmltopdf library?

I tried with

div.page
{
    page-break-after: always;
    page-break-inside: avoid;
    border: 5px double !important;
}

but no luck.

Simmilar question : add border to pages printed using wkhtmltopdf

EDIT : enter image description here

1

There are 1 best solutions below

0
On

Simply create an HTML page with below CSS and try to generate pdf file using wkhtmltopdf

<html>
<head>
<style>
 body {
  width: 100%;
  height: 2000px;
  margin: 0;
  padding: 0;
}

.border {
  position: fixed;
  top: 0;
  left: 0;
  border: 5px double;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  page-break-after: always;
  page-break-inside: avoid;
  box-sizing: border-box;
}
</style>
</head>
<body>
<div class="border"></div>
</body>
</html>