Added examples, tweaked print job
This commit is contained in:
parent
d03428a2e4
commit
0c684980da
17
examples/print.php
Normal file
17
examples/print.php
Normal 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
13
examples/simple.php
Normal 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();
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user