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

Error when using loadPDF function with WindowsPrintConnector #1351

Open
brunogambeta opened this issue Aug 21, 2024 · 0 comments
Open

Error when using loadPDF function with WindowsPrintConnector #1351

brunogambeta opened this issue Aug 21, 2024 · 0 comments

Comments

@brunogambeta
Copy link

Good morning everyone. I'm trying to use the ImagickEscposImage::loadPdf function, but it's returning an Exception: Below is my code snippet and the error it's presenting.

$item = Nfce::findOrFail($id);
$empresa = $item->empresa;
$nomeImpressora = "POS-80-Series";
$connector = new WindowsPrintConnector($nomeImpressora);
$printer = new Printer($connector);
$saveDirectory = 'danfce/' . $empresa->cpf_cnpj;

   $nomeArquivo = $item->id;
    if ($item->chave) {
        $nomeArquivo = $item->chave;
    }

    $pdf = public_path($saveDirectory . '/'. $nomeArquivo . '.pdf');
    try {
        $pages = ImagickEscposImage::loadPdf($pdf,260);
        foreach ($pages as $page) {
            $printer -> graphics($page);
        }
        $printer -> cut();
    } catch (Exception $e) {
        /*
         * loadPdf() throws exceptions if files or not found, or you don't have the
         * imagick extension to read PDF's
         */
        echo $e -> getMessage() . "\n";
    } finally {
        $printer -> close();
    }

Error: FailedToExecuteCommand `"gs" -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r2x2" -dPrinted=false "-sOutputFile=C:/Windows/TEMP/magick-xk9qK0jkSZxZhpPP60nDfPUHc1JHqjKv%d" "-fC:/Windows/TEMP/magick-f_4PYAkoQKYWA4qgbZhJaqdPCnhJo9dy" "-fC:/Windows/TEMP/magick-hTXMzE5m8BJhdQZdixl3kQmLz6PuqNlD"' (O sistema n�o pode encontrar o arquivo especificado. ) @ error/delegate.c/ExternalDelegateCommand/516

I'm using php 8.2.12.

If anyone can help me, I would appreciate it; Thank you

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