PHP code example of exchangecore / webprint

1. Go to this page and download the library: Download exchangecore/webprint library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

exchangecore / webprint example snippets



$printer = new exchangecore\webprint\src\printers\WebPrinter();
$printer
    ->setBaseReference(0.25, 0.25, $printer::UNIT_INCHES)
    ->setFontSize(20)
    ->outputText('HELLO WORLD')
    ->setPosition(0, 0.25, $printer::UNIT_INCHES)
    ->outputCode39('*123456789*', 16, $printer::UNIT_POINT, 4)
    ->processCommandStack();


$printer = new exchangecore\webprint\src\printers\sato\M8400rve();
$printer                       
    ->setPaperWidth(4, $printer::UNIT_INCHES)
    ->setBaseReference(0.25, 0.25, $printer::UNIT_INCHES)
    ->setFontSize(20)
    ->outputText('HELLO WORLD')
    ->setPosition(0, 0.25, $printer::UNIT_INCHES)
    ->outputCode39('*123456789*', 16, $printer::UNIT_POINT, 4)
    ->setCopies(3);
    
if($printer->connect('10.1.0.49')){
    if($printer->processCommandStack(false)) {
        echo 'Printed Successfully';    
    } else {
        echo 'Failed to print';
    }
    $printer->disconnect();
} else {
    echo 'Failed to connect';
};