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!';
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);
} catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ?>
`