mike42 / escpos-php

PHP library for printing to ESC/POS-compatible thermal and impact printers
Other
2.51k stars 855 forks source link

Print PDF document via print-from-pf.php #686

Closed mountainclimbing closed 5 years ago

mountainclimbing commented 5 years ago

Hello, Am looking at the example, "print-from-pdf.php'. ---------php start-------- require(DIR . '..\vendor\autoload.php'); use Mike42\Escpos\Printer; use Mike42\Escpos\ImagickEscposImage; use Mike42\Escpos\PrintConnectors\NetworkPrintConnector; use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;

$pdf = "document.pdf"; $connector = new WindowsPrintConnector("HP DeskJet 1011 series"); $printer = new Printer($connector); try { $pages = ImagickEscposImage::loadPdf($pdf); foreach ($pages as $page) { $printer -> graphics($page); } $printer -> cut(); } catch (Exception $e) { /*

"exception 'ImagickException' with message 'PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/801' in C:\wamp\www\print\vendor\mike42\escpos-php\src\Mike42\Escpos\ImagickEscposImage.php:228 Stack trace: #0 C:\wamp\www\print\vendor\mike42\escpos-php\src\Mike42\Escpos\ImagickEscposImage.php(228): Imagick->readimage('C:\wamp\www\pri...') #1 C:\wamp\www\print\example\print-from-pdf.php(24): Mike42\Escpos\ImagickEscposImage::loadPdf('C:\wamp\www\pri...') #2 {main} "

What are I missing?

mike42 commented 5 years ago

@mountainclimbing - the stack trace includes 'PDFDelegateFailed', which indicates that your ImageMagick setup is not able to process PDF files. This is not an escpos-php issue, and should be solved through other channels.

Aside, your printer does not understand the ESC/POS language that this library produces, and will print garbage. See "I have a printer that does not understand ESC/POS. Can I use this driver?" in the FAQ.

truchosky commented 4 years ago

I had the same problem, garbage print every time, but I changed $printer -> graphics() for $printer -> bitImage() and it works

s2b-git commented 6 months ago

I had the same problem, garbage print every time, but I changed $printer -> graphics() for $printer -> bitImage() and it works

Did that, and no more garbage, but POS printing like old impact printer. How to speed it up?