Added examples, tweaked print job

This commit is contained in:
Chris 2017-10-31 18:10:39 +01:00
parent d03428a2e4
commit 0c684980da
3 changed files with 36 additions and 0 deletions

17
examples/print.php Normal file
View File

@ -0,0 +1,17 @@
<?php
require_once __DIR__."/../vendor/autoload.php";
use NoccyLabs\Lpr\PrintJob;
$job = new PrintJob("image.png");
// Configure
$job->setPrinter("QL-570");
$job->setMedia("A4");
// Additional options can be set like this
$job->setOption("fit-to-page", true);
// Invoke lpr to print the image
$job->submit();

13
examples/simple.php Normal file
View File

@ -0,0 +1,13 @@
<?php
require_once __DIR__."/../vendor/autoload.php";
use NoccyLabs\Lpr\PrintJob;
$job = new PrintJob("image.png");
// Configure
$job->setPrinter("PDF");
// Invoke lpr to print the image
$job->submit();

View File

@ -94,6 +94,12 @@ class PrintJob
*/
public function submit()
{
if (!file_exists($this->document)) {
throw new LprException(
sprintf("The document could not be printed because the file could not be found: %s", $this->document)
);
}
$options = [];
if ($this->server !== null) {
$options[] = "-H";