Margin problem when generating PDF with MPDF

Asked

Viewed 251 times

1

I need to know how to take the margin or edge of the mpdf pages, at first I wanted to create a pdf file that had the first page with this background = background: linear-gradient( 40deg, #4169E1 50%, white 50% );, but if I put it in <body>, the background appears on all other pages I create after, even with the break code pages <pagebreak>,then I thought of the solution to put inside a <div>, but it does not occupy the height and width 100%(Obs: even if I put it with height and width 100% in css), then it doesn’t stick to the background I want, so I would like to know or how do I take the edge and margin of the sheet or how do I do so when I break a page it doesn’t pull the css from the body ancient.

require_once __DIR__ . '/vendor/autoload.php';

use Mpdf\Mpdf;
$mpdf = new Mpdf();

$mpdf->WriteHTML('<body style="border:0px; height:100% width:100%;">
<div style="background-color: solid;
height:100%;
border:0px;
width:100%;
background:  linear-gradient( 40deg, #4169E1 50%, white 50% );
margin:0px;
padding:0px;">
<section >

<p style="font-size:32pt; padding-bottom:0pt; padding-top: 110pt;padding-left: 170pt;text-indent: 0pt;text-align: Left;">Proposta Comercial</p>

<img src="C:\xampp\htdocs\wordpress\wp-content\themes\wp-bootstrap-starter\imgs\Logo_Grupo-Avante.png" alt="some text" style="padding:0px; margin-top:450px;" width=511 >

</section></div></body><pagebreak>');

$mpdf->WriteHTML('<div style="background-color: solid; background: white; height:100%;
width:100%; ">'. $page_1 .'</div>');

I wanted in case put only the first page with this style

style="background-color: solid;
    height:100%;
    border:0px;
    width:100%;
    background:  linear-gradient( 40deg, #4169E1 50%, white 50% );
    margin:0px;
    padding:0px;"

The style within the div gets like this:

The style within the body gets like this:

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.