1. Go to this page and download the library: Download faerber/pdf-to-zpl 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/ */
faerber / pdf-to-zpl example snippets
use Faerber\PdfToZpl\PdfToZplConverter;
use Faerber\PdfToZpl\Settings\ConverterSettings;
use Faerber\PdfToZpl\Settings\ImageScale;
// By default this will convert a 4x6 label
$converter = new PdfToZplConverter();
// Get an array of ZPL commands (1 per page)
$pages = $converter->convertFromFile("myFile.pdf");
// Or from a blob:
$pages = $converter->convertFromBlob(file_get_contents("myFile.pdf"));
foreach ($pages as $page) {
// Each page is a single ZPL statement
assert(str_starts_with($page, "^XA^GFA,"));
}
use Faerber\PdfToZpl\ImageToZplConverter;
$converter = new ImageToZplConverter();
// Get an array of ZPL commands (1 per page)
[$zpl] = $converter->convertFromFile("myFile.png");
assert(str_starts_with($zpl, "^XA^GFA,"));
use Faerber\PdfToZpl\LabelImage;
use Faerber\PdfToZpl\Settings\LabelDirection;
$zpl = "^XA_ZPL_DATA_HERE...";
$labelImage = new LabelImage(
zpl: $zpl,
direction: LabelDirection::Up,
);
$labelImage->saveAs("my_label.png");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.