getComputers(); $printers = $request->getPrinters(); $printJobs = $request->getPrintJobs(); // Hint: The return value from these methods is always an array containing 0 or more // instances of PrintNode\Computer, PrintNode\Printer or PrintNode\PrintJob depending // on the method called. You can iterate over this array however you please, for example // you might use a while or foreach loop. // Step 4: Send a PrintJob to Printnode. // PrintNode currently only accepts PDF documents. // To print something, you need to create a new instance of PrintNode\PrintJob: $printJob = new PrintNode\PrintJob(); // You can then populate this object with the information about the print-job // and add the base64-encoded content of, or the URI to your PDF. To do this use the properties // as defined on the object. // // In this example, we're going to print a a base64-encoded PDF named invoice.pdf: $printJob->printer = $printers[1]; $printJob->contentType = 'pdf_base64'; $printJob->content = base64_encode(file_get_contents('a4_portrait.pdf')); $printJob->source = 'My App/1.0'; $printJob->title = 'Test PrintJob from My App/1.0'; // Hint: The PrintNode PHP API comes complete with PHPDoc comments. // If you have an editor that supports PHPDoc code completion, you should see hints // for the properties and method names on each of the objects. // Once you have populated the object, all that's left to do is submit it: $response = $request->post($printJob); // The response returned from the post method is an instance of PrintNode\Response. // It contains methods for retrieving the response headers, body and HTTP status-code and message. // Returns the HTTP status code. $statusCode = $response->getStatusCode(); // Returns the HTTP status message. $statusMessage = $response->getStatusMessage(); // Returns an array of HTTP headers. $headers = $response->getHeaders(); // Return the response body. $content = $response->getContent();