1

Is there a way to remove this white boarder that's added on the output when using pdfkit? Excuse the awful colour selection...

This isn't something I've added in the .html file. However it may be worth noting that i've forced the body size of the html file to be that of an A4 sheet;

<style>
    body {
        width: 794px;
        height: 1122px;
        margin: 0;
        padding: 0;
        background-color: green;

In addition, when I output using pdfkit these are my settings;

import pdfkit

options = {
    'page-size': 'A4',
    'dpi': 400}

pdfkit.from_string(html_out, '/Users/harryrobinson/Desktop/aaa.pdf', options=options)

I also tried using the the 'print-media-type':True - however, this just generates an error.

Thanks for any help that can be provided!

Hazzamataza
  • 983
  • 2
  • 12
  • 25

2 Answers2

0

An A4 Page with 400dpi is 3307 x 4677 pixels.

Did you try:

width: auto;
height: auto;
margin-top: 0px;
David
  • 1,084
  • 12
  • 36
  • 2
    Thanks for response. I believe pdfkit does the conversion to 400dpi - by fixing the html file to 794px x1122px ensures the output 'looks A4'. However, neither solution resolves the white boarder around the outside. I'm assuming this is related to pdfkit, as it doesn't show on the html when loaded in the browser – Hazzamataza Oct 12 '17 at 14:46
0

try making all the margins to 0px

width: auto;
height: auto;
margin-top: 0px;
margin-top: 0px;
margin-bottom :0px;
margin-left :0px;
margin-right:0px;