Search code examples
phplaravelpdfdompdf

How to make pdf exact 10CM width with DOMPDF and Laravel?


I am creating a PDF with DOMPDF and laravel.

The pdf is being printed with a special printer that only accepts files with 10CM width and 20CM height.

I have tried this:

$customPaper = array(0,0,720,1440);
$pdf = PDF::loadView('pdf.retourlabel',compact('retour','barcode'))->setPaper($customPaper);

Since 11X17 is

"11x17" => array(0, 0, 792.00, 1224.00),

I figured 10X20 was 0,0720,1440

But it's not working.

Any help is appreciated.

Thanks in advance


Solution

  • How i fixed this:

    change the custom paper.

    Download the PDF open in Acrobat Reader move your mouse to the left corner now you can see the width and height of the document, and i changed the custom paper accordingly.

    The end result was: 10CM X 20CM =

    $customPaper = array(0,0,567.00,283.80);
    $pdf = PDF::loadView('pdf.retourlabel', compact('retour','barcode'))->setPaper($customPaper, 'landscape');
    

    Very circuitous work but i did get the Job done..

    Thanks