barryvdh / laravel-dompdf

A DOMPDF Wrapper for Laravel
MIT License
6.62k stars 965 forks source link

show barcode and title in one paper with barryvdh/laravel-dompdf #975

Open atrialabir opened 1 year ago

atrialabir commented 1 year ago

I use barryvdh/laravel-dompdf package in laravel to make pdf files and print them.

my printer machine print barcode in small dimension like 45mm * 30mm

I use this code to make pdf like

        $pdf = new Dompdf(new Options(['dpi' => 200]));
        $pdf->loadHtml('
        <img  src="data:image/png;base64,' . base64_encode($barcode) . '">
        <br/>
        <span style="text-align:center;">' . $code . '</span>
        <br/>
        <span>' . $product->name . '(' . $brand->name . ')</span>
        ');
        $pdf->setPaper([0, 0, 127, 85]);
        $pdf->render();

        $name = $code . '.pdf';
        $path = 'barcodes/' . $name;
        Storage::disk('public')->put($path, $pdf->output());

and the result is:

enter image description here

how can I fit all content in one page not three page

parallels999 commented 1 year ago

https://github.com/barryvdh/laravel-dompdf/blob/424a223ce80e7afc8bfb6e84449679efe272fbb5/.github/ISSUE_TEMPLATE/bug_report.md?plain=1#L10-L12

This is just a Dompdf wrapper! I understand that this package is just a Laravel wrapper for https://github.com/dompdf/dompdf Any issues with PDF rendering, CSS that is not applied correctly, aligning/fonts/characters etc that are not directly related to this package, should be reported there. When having doubts, please try to reproduce the issue with just dompdf. If it's also present there, do not open an issue here please.

ntaylor-86 commented 1 year ago

@atrialabir Setup your template (HTML & CSS) so that it creates a template to suit your labels dimensions.