nextcloud-printer/lib/Service/Printer.php

45 lines
853 B
PHP

<?php
namespace Service;
namespace OCA\Printer\Service;
use Symfony\Component\Process\Process;
/**
* class Printer.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class Printer
{
public function print(string $file, string $orientation)
{
$options = [
'landscape' => [
'lpr',
$file,
],
'portrait' => [
'lpr',
'-o',
'orientation-requested=4',
$file,
],
];
$process = new Process($options[$orientation]);
$process->mustRun();
}
/**
* Validates an orientation.
*/
public function isValidOrirentation(string $orientation): bool
{
return in_array($orientation, [
'landscape',
'portrait',
]);
}
}