Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shing_shing's avatar

DomPdf: Receipt Printing

Good day!

Dompdf is working fine.

This is our standard paper size:

$pdf = PDF::loadView('pdf.or_spct', $data)->setPaper('8.5x11', 'portrait');

But client wants to cut it in half so I tried the code below My preview is okay,

but when we print the output, it's not working:

$pdf = PDF::loadView('pdf.or_spct', $data)->setPaper(array(0,0,'396','612'),'landscape');

It just printed it whole page.

I even tried to customize the paper size in my css, but still no changes.

  1. Dompdf Generated Receipt Link: https://drive.google.com/file/d/10d2YFO9Gc97twbN__N3uBpkGuyN4_Pw3/view?usp=sharing
  2. Preview when to be printed and also the exact output when printed: https://drive.google.com/file/d/1O_YBb4UQ9P67Q_Uq2N_M2iWJ6nkO3LlL/view?usp=sharing
0 likes
2 replies
bobbybouwmann's avatar

The code looks correct to me. One thing that could be the issue is that you're using strings instead of integers to pass in the number. Can you try this instead?

$pdf = PDF::loadView('pdf.or_spct', $data)->setPaper(array(0, 0, 396, 612), 'landscape');

Please or to participate in this conversation.