Reputation: 183
I'm creating a PDF file from a source file that is 119.88 x 50.058 mm. However, when i place a QR code, I cannot make it bigger whether i specify it with size 50 or 500, no different. What do i need to do to make the QR code bigger?
Here is my code
$pdf = new FPDI('L', 'mm', array('119.888','50.038'));
$pdf->setPrintHeader(false);
$pdf->AddPage();
$page = $pdf->setSourceFile('aw_print.PDF');
$page = $pdf->ImportPage(1, 'TrimBox');
$pdf->useTemplate($page, 0, 0);
$x = 10;
$y = 10;
$style = array(
'border' => 1,
'vpadding' => 'auto',
'hpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false, //array(255,255,255)
'module_width' => 1, // width of a single module in points
'module_height' => 1 // height of a single module in points
);
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', 10, 10, 60, 60, $style, 'N');
$pdf->Output('test.PDF', 'D');
Result of size 60 https://prnt.sc/i8yva3
Result of size 500 https://prnt.sc/i8yvkt
Upvotes: 0
Views: 2889
Reputation: 2643
$pdf = new FPDI('L', 'mm', array('119.888','50.038'));
$pdf->setPrintHeader(false);
Add SetAutoPageBreak
and set it to false
. This will make sure that style
works as expected.
$pdf->SetAutoPageBreak(false); // important so styles don't break
$pdf->AddPage();
$page = $pdf->setSourceFile('aw_print.PDF');
$page = $pdf->ImportPage(1, 'TrimBox');
$pdf->useTemplate($page, 0, 0);
$x = 10;
$y = 10;
$style = array(
'border' => 1,
'vpadding' => 'auto',
'hpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false, //array(255,255,255)
'module_width' => 1, // width of a single module in points
'module_height' => 1 // height of a single module in points
);
By default a barcode is confined to the page and margin size.
Adding true
for distort will enable you to scale to what ever size.
// write2DBarcode($code, $type, $x, $y, $w, $h, $style, $align, $distort) {
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', 10, 10, 60, 60, $style, 'N', true);
$pdf->Output('test.PDF', 'D');
Now that you are able to scale past the margins and page size style
will not render properly unless you followed the first step and added SetAutoPageBreak
.
Upvotes: 1