PHP mPDF barcode problems

Asked

Viewed 224 times

0

I receive a URL of a billet generated in ASP, use the mPDF class to send this billet to the server, recover the generated billet and send by email with Phpmailer. What happens is that in gmail the barcode of the boleto is different from when I access directly through the URL

AN EXAMPLE OF THE ASP BILLET BARCODE

inserir a descrição da imagem aqui

BOLETO BAR CODE GENERATED WITH mPDF

inserir a descrição da imagem aqui

these are the same boletos, but with different barcode. Follow an example of the code where I accept the boleto with mPDF:

$location = '/usr/local/se/web/wwwroot/temp/';

$url = file_get_contents($path);

$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4', [197, 296]]);
$mpdf->allow_charset_conversion = true;
$mpdf->SetDisplayMode('fullpage');
$mpdf->writeHTML($url);

ob_clean();

$pathArchive = $location . createRandomOID() . '.pdf';

$mpdf->Output($pathArchive);

return $pathArchive;

any tips on how to fix it? I’ve read the mPDF documentation and nothing has been resolved.

1 answer

0

RESOLVED

i solved with PHP’s str_replace function, changed the width of the barcode pixels, thus:

$url = file_get_contents($path);

//troca os pixels de largura do código de barras do boleto
$new_url = str_replace(array('img src=http://boletos.schulze.com.br/p.gif width=1 height=50 border=0','img src=http://boletos.schulze.com.br/b.gif width=1 height=50 border=0'), array('img src=http://boletos.schulze.com.br/p.gif width=1.5 height=50 border=0','img src=http://boletos.schulze.com.br/b.gif width=1.5 height=50 border=0'), $url);

and so the PDF file was attached with all bars in the email.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.