<?php /** * File: examples/sendFile.php * Author: Robin Rijkeboer <*****@*****.**> */ //Require the client require_once '../lib/QanvasClient/Client.php'; //Setup client, first argument is the API key, second one is the Qanvas URL $client = new QanvasClient\Client('b79a708ac2c9979b36e0465c04041d394035956db0377f9ca901ab7eb6303df3', 'http://localhost/qanvas-prototype/Master/web/app_dev.php'); //The path to the document $pathToDocument = "/home/robin/Qanvas Update/Test documents/prooftemplate.odt"; //Data array, fill in anything that has been declared in the document here. $dataArray = array('dummy' => 'data'); //Where does it need to convert to? Default is PDF so you can leave this blank $format = "pdf"; //Sends the document out for processing, you'll get back an array or an error if one is found. $result = $client->processDocument($pathToDocument, array(), $format); //For example purposes, die and show the variables in $result die(var_dump($result));
/** * File: examples/workflow.php * Author: Robin Rijkeboer <*****@*****.**> */ //Require the client require_once '../lib/QanvasClient/Client.php'; //Setup client, first argument is the API key, second one is the Qanvas URL $client = new QanvasClient\Client('b79a708ac2c9979b36e0465c04041d394035956db0377f9ca901ab7eb6303df3', 'http://localhost/qanvas-prototype/Master/web/app_dev.php'); //First we make some data: $data = array('color' => 'red', 'name' => 'Qanvas Demo', 'grades' => array('rocketscience' => 5.3, 'programmingskills' => 7.5, 'nature' => 10.0)); //Now where is that document located that we wanted? $file = "Doc/Workflow_example.odt"; //What format do we want? $format = "pdf"; //Sends the document out for processing, you'll get back an array or an error if one is found. $enqueuedDocument = $client->processDocument($file, $data, $format); if ($enqueuedDocument['status'] == 0) { $token = $enqueuedDocument['token']; while ($client->checkDocumentStatus($token)['status'] == 0) { usleep(500000); } $processedDocument = $client->downloadDocument($token); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=workflow.' . $format); header('Content-Length: ' . strlen($processedDocument)); echo $processedDocument; exit; } else { die($enqueuedDocument['status']); }