How can I set a paper size in php? for example: I have a paper of 140mm x 160mm.
How can I set a paper size in php? for example: I have a paper of 140mm x 160mm.
A tip, whenever I faced the problem I used some library to generate PDF files, FPDF is old but solves these problems.It goes generate the PDF of the paper size you need. A minimal example
<?php
require('fpdf.php');
//aqui vc personiza o tamanho do papel
$pdf = new FPDF('P','mm',array(140,160));
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>
Another option is DomPdf (convert html to pdf)
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');
$customPaper = array(0,0,140,160); //personaliza aqui
$dompdf->set_paper($customPaper);
I prefer FDPF because it's faster