From 0c684980da34f8691d19efde8a652afb416f759c Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Tue, 31 Oct 2017 18:10:39 +0100 Subject: [PATCH] Added examples, tweaked print job --- examples/print.php | 17 +++++++++++++++++ examples/simple.php | 13 +++++++++++++ src/PrintJob.php | 6 ++++++ 3 files changed, 36 insertions(+) create mode 100644 examples/print.php create mode 100644 examples/simple.php diff --git a/examples/print.php b/examples/print.php new file mode 100644 index 0000000..6563a0a --- /dev/null +++ b/examples/print.php @@ -0,0 +1,17 @@ +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(); \ No newline at end of file diff --git a/examples/simple.php b/examples/simple.php new file mode 100644 index 0000000..9e0ae5c --- /dev/null +++ b/examples/simple.php @@ -0,0 +1,13 @@ +setPrinter("PDF"); + +// Invoke lpr to print the image +$job->submit(); diff --git a/src/PrintJob.php b/src/PrintJob.php index 5c98437..695cfd1 100644 --- a/src/PrintJob.php +++ b/src/PrintJob.php @@ -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";