barryvdh / laravel-snappy

Laravel Snappy PDF
MIT License
2.59k stars 289 forks source link

How to generate PDF file full size #515

Open Dominik-Kapitan opened 9 months ago

Dominik-Kapitan commented 9 months ago

Hi.

In laravel 10 I'm using wkhtmltopd library to generate pdf document.

The problem is when I try generate content in full width of ducument, top and sides. Some reason there is always white border on the right side Screenshot from 2023-09-26 12-29-38

This is my html code that I use to generate document:

<!DOCTYPE html>
<html style="margin: 0; padding: 0; background-color: #fd7e14">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Title</title>
<link rel="stylesheet" media="screen" href="https://fontlibrary.org//face/open-sauce-one" type="text/css"/>
<meta name="author" content="name author">
<style media="all">
    html {
        margin: 0 !important;
        padding:0 !important;
        border:0 !important;
        outline:0 !important;
    }
    body {
        margin: 0 !important;
        padding:0 !important;
        border:0 !important;
        outline:0 !important;
    }
</style>
</head>

<body>
   Test Content
</body>
</html>

And this is my PHP render code:

$pdf->setPaper('A4', 'portrait')->setOptions([
                'margin-left' => 0,
                'margin-right' => 0,
                'margin-top' => 0,
                'margin-bottom' => 0,
            ])->save($pathToStore);

How can I remove that white space?

jonnywilliamson commented 6 months ago

I'm literally just browsing here, but have you tried a negative margin right? Maybe -1 or -2?