escpos-php icon indicating copy to clipboard operation
escpos-php copied to clipboard

basic Samsung laser printer

Open CHILLTH opened this issue 1 year ago • 1 comments
trafficstars

Hi guys! Trying to test printing pdf via IP as per below code, however it doesnt printing out PDF content but some random chars and mostly blank pages. What should be done?

`<?php require 'vendor/autoload.php'; // Include the escpos-php library

use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;

use Mike42\Escpos\Printer; use Mike42\Escpos\ImagickEscposImage;

// IP address and port of the printer server $printerIP = 'MYIP'; $printerPort = 9100;

try { // Create a network connector to the printer $connector = new NetworkPrintConnector($printerIP, $printerPort);

// Create a new Printer object
$printer = new Printer($connector);

// Path to the PDF file you want to print
$pdfFilePath = 'sample.pdf';

$pages = ImagickEscposImage::loadPdf($pdfFilePath, 260);
foreach ($pages as $page) {
    $printer -> graphics($page, Printer::IMG_DOUBLE_HEIGHT | Printer::IMG_DOUBLE_WIDTH);
}

$printer->cut();
$printer -> close();

echo 'PDF printed successfully!';

} catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ?>

`

CHILLTH avatar Nov 24 '23 23:11 CHILLTH

Happy to hire for that too :)

CHILLTH avatar Nov 25 '23 01:11 CHILLTH