-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathquexmlpdf_example.php
More file actions
41 lines (31 loc) · 1.19 KB
/
quexmlpdf_example.php
File metadata and controls
41 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* Example use of the queXMLPDF class
* Create a PDF and queXF banding XML file from the test_questionnaire file
* and output it in a ZIP archive
*
* Currently available for use online at:
* https://surveys.acspri.org.au/quexmltools/
*
*/
require_once('quexmlpdf.php');
// create new queXMLPDF document
$quexmlpdf = new queXMLPDF(PDF_PAGE_ORIENTATION, 'mm', PDF_PAGE_FORMAT, true, 'UTF-8', false);
set_time_limit(120);
$quexmlpdf->create($quexmlpdf->createqueXML(file_get_contents("test_questionnaire.xml")));
//NEED TO GET QID from $quexmlpdf
$qid = intval($quexmlpdf->getQuestionnaireId());
$zip = new ZipArchive();
$filename = tempnam("/tmp", "queXMLPDF") . ".zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open temporary file\n");
}
$zip->addFromString("quexf_banding_$qid.xml", $quexmlpdf->getLayout());
$zip->addFromString("quexmlpdf_$qid.pdf", $quexmlpdf->Output("quexml_$qid.pdf", 'S'));
$zip->close();
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="quexmlpdf_' . $qid . '.zip"');
header('Content-Transfer-Encoding: binary');
// load the file to send:
readfile($filename);
unlink($filename);