Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possível solução para corrigir lentidão na impressão da CT-e #580

Open
SmileYzn opened this issue Aug 31, 2023 · 0 comments
Open

Possível solução para corrigir lentidão na impressão da CT-e #580

SmileYzn opened this issue Aug 31, 2023 · 0 comments

Comments

@SmileYzn
Copy link

SmileYzn commented Aug 31, 2023

Acabei descobrindo o porque da lentidão ao gerar o danfe CT-e:

https://github.com/nfephp-org/sped-da/blob/c4634d8fbb1b352010fe0617497a4e25f124330f/src/CTe/Dacte.php#L3809C39-L3809C39

Essa funcão está usando a extensão imagick, passar false para usar o PHP GD e whoala, é insantâneo a geração do documento.

E acabei modificando um pouco essa função qrCodeDacte, para salvar o arquivo qrcode.png de uma forma temporária, pois nem todo servidor PHP está com allow_url_fopen ativo:

protected function qrCodeDacte($y = 0)
{
    $margemInterna = $this->margemInterna;
    $barcode = new Barcode();
    $bobj = $barcode->getBarcodeObj(
        'QRCODE,M',
        $this->qrCodCTe,
        -4,
        -4,
        'black',
        array(-2, -2, -2, -2)
    )->setBackgroundColor('white');
    $qrcode = $bobj->getPngData(false);
    $wQr = 36;
    $hQr = 36;
    $yQr = ($y + $margemInterna);
    if ($this->orientacao == 'P') {
        $xQr = 170;
    } else {
        $xQr = 250;
    }
    file_put_contents('qrcode.png', $qrcode);
    $this->pdf->image('qrcode.png', $xQr - 3, $yQr, $wQr, $hQr, 'PNG');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant