Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set margins with SetMargins #1903

Open
1 task done
medilies opened this issue Jul 8, 2023 · 1 comment
Open
1 task done

Cannot set margins with SetMargins #1903

medilies opened this issue Jul 8, 2023 · 1 comment
Milestone

Comments

@medilies
Copy link

medilies commented Jul 8, 2023

Guidelines

Description of the bug

SetMargins does not support margin-bottom as the constructor config does, plus margin-left and margin-right are not taken into consideration.

This how I fixed the output in my project row-bloom/row-bloom@683fcd4

mPDF version

v8.1.6

PHP Version and environment (server type, cli provider etc., enclosing libraries and their respective versions)

PHP 8.1.6 (Simply running a script with php ./script.php)

Reproducible PHP CSS HTML snippet suffering by the error

// script.php

use Mpdf\HTMLParserMode;
use Mpdf\Mpdf;

$mpdf = new Mpdf();

$mpdf->SetMargins(50,50,50);

$mpdf->SetHeader('foo');
$mpdf->SetFooter('foo');
$mpdf->WriteHTML('<p>foo</p>');
$mpdf->WriteHTML('', HTMLParserMode::HEADER_CSS);

$mpdf->OutputFile(__DIR__.'./bar.pdf');
@finwe
Copy link
Member

finwe commented Sep 1, 2023

It seems that SetMargins is a method taken over from FPDI, not documented and not (even unofficially) supported in mPDF. Use other methods of setting margins - as parameters of Mpdf\Mpdf constructor, parameters of AddPage/AddPageByArray or by properties of <pagebreak> tag. The SetMargins method will eventually be deprecated and removed.

@finwe finwe added this to the 9.0 milestone Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants