<?php

/**
 * File: examples/downloadDocument.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');
//Downloads the document into the result string
$result = $client->downloadDocument('5ffc6876821c184bf78934a7e3e7d49c');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=test.pdf');
header('Content-Length: ' . strlen($result));
echo $result;
exit;
//die(var_dump($result));
Esempio n. 2
0
<?php

/**
 * 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']);
Esempio n. 3
0
<?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));
<?php

/**
 * File: examples/documentStatus.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');
//Sends the token to check if the document is done, you'll get back an array or an error if one is found.
$result = $client->checkDocumentStatus('24cc9989646b804986b272ad9f060bad');
//For example purposes, die and show the variables in $result
die(var_dump($result));
//Examples what you can do with this:
//Check the status, 1 is processed, 0 is still processing.
if ($result['status'] == 1) {
    echo "The document has been processed.";
} else {
    if ($result['status'] == 0) {
        echo "The document is still processing.";
    }
}