smalot / cups-ipp

CUPS Implementation of IPP - PHP Client API
GNU General Public License v2.0
107 stars 56 forks source link

Bad Request (HTTP 400) #7

Closed c-scholz-acribit closed 6 years ago

c-scholz-acribit commented 6 years ago

I am using the library inside a Laravel 5.6 application.

When I try to print a document I get an exception (HTTP-Statuscode 400 - "Bad Request").

$client = new Client('scholz', '123456');
$builder = new Builder();
$responseParser = new ResponseParser();

$printerManager = new PrinterManager($builder, $client, $responseParser);
$printer = $printerManager->findByUri('ipp://localhost:631/printers/inpas');

$jobManager = new JobManager($builder, $client, $responseParser);

$job = new Job();
$job->setName($printjob->title);
$job->setUsername('scholz');
$job->addFile('./storage/app/'.$printjob->file);
$job->addAttribute('media', $printjob->format);
$job->addAttribute('orientation-requested', $printjob->orientation);
$job->addAttribute('fit-to-page', true);
$job->setPageRanges($printjob->range);

$result = $jobManager->send($printer, $job);

Check a screenshot of the Exception here: https://www2.pic-upload.de/img/35784064/Bildschirmfotovom2018-08-1316-47-35.png

Any ideas what I could try? The provided data in the $printjob Object is correct, too, because I fixed any errors with this by now. Also I added www-data user (Apache) to lp usergroup in Ubuntu.

I am just wondering how I'd maybe get around this 400 error and finally print a pdf...

c-scholz-acribit commented 6 years ago

Okay I came to the conclusion that actually some provided values were wrong or I called them wrongly. Here's what I found out or need help with @smalot

c-scholz-acribit commented 6 years ago

Duplicate of https://github.com/smalot/cups-ipp/issues/2

chriskonnertz commented 5 years ago

It might also be worth a note, that there is no straight way to print "all" pages of a document. setPageRanges() cannot be ommitted,so we have to specify a range. One solution is to use something like `setPageRanges('1-99')' - just set the max range value to a high value that you hopefully will never exceed.