<?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);
$quexmlpdf->importStyleXML(file_get_contents($_FILES['stylefile']['tmp_name'])); } else { if ($_POST['eformat'] == "boxes") { $quexmlpdf->setCornerBoxes(); } $quexmlpdf->setStyle($_POST['style']); $quexmlpdf->setResponseTextFontSize($_POST['responseTextFontSize']); $quexmlpdf->setSectionHeight($_POST['sectionHeight']); $quexmlpdf->setBackgroundColourQuestion($_POST['backgroundColourQuestion']); $quexmlpdf->setBackgroundColourSection($_POST['backgroundColourSection']); $quexmlpdf->setSingleResponseAreaHeight($_POST['singleResponseAreaHeight']); $quexmlpdf->setSingleResponseHorizontalHeight($_POST['singleResponseHorizontalHeight']); $quexmlpdf->setQuestionnaireInfoMargin($_POST['questionnaireInfoMargin']); $quexmlpdf->setResponseLabelFontSize(array($_POST['responseLabelFontSize'], $_POST['responseLabelFontSizeSmall'])); } $quexmlpdf->create($quexmlpdf->createqueXML(file_get_contents($filename))); //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_style_{$qid}.xml", $quexmlpdf->exportStyleXML()); $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:
// Set the language of the survey, either from GET parameter of session var if (isset($_GET['lang'])) { $_GET['lang'] = preg_replace("/[^a-zA-Z0-9-]/", "", $_GET['lang']); if ($_GET['lang']) { $surveyprintlang = $_GET['lang']; } } else { $surveyprintlang = GetbaseLanguageFromSurveyid($surveyid); } // Setting the selected language for printout $clang = new limesurvey_lang($surveyprintlang); $quexmlpdf = new queXMLPDF(PDF_PAGE_ORIENTATION, 'mm', PDF_PAGE_FORMAT, true, 'UTF-8', false); set_time_limit(120); $noheader = true; include_once "export_structure_quexml.php"; $quexmlpdf->create($quexmlpdf->createqueXML($quexml)); //NEED TO GET QID from $quexmlpdf $qid = intval($quexmlpdf->getQuestionnaireId()); $zipdir = tempdir($tempdir); $f1 = "{$zipdir}/quexf_banding_{$qid}_{$surveyprintlang}.xml"; $f2 = "{$zipdir}/quexmlpdf_{$qid}_{$surveyprintlang}.pdf"; $f3 = "{$zipdir}/quexml_{$qid}_{$surveyprintlang}.xml"; $f4 = "{$zipdir}/readme.txt"; file_put_contents($f1, $quexmlpdf->getLayout()); file_put_contents($f2, $quexmlpdf->Output("quexml_{$qid}.pdf", 'S')); file_put_contents($f3, $quexml); file_put_contents($f4, $clang->gT('This archive contains a PDF file of the survey, the queXML file of the survey and a queXF banding XML file which can be used with queXF: http://quexf.sourceforge.net/ for processing scanned surveys.')); require_once "classes/phpzip/phpzip.inc.php"; $z = new PHPZip(); $zipfile = "{$tempdir}/quexmlpdf_{$qid}_{$surveyprintlang}.zip"; $z->Zip($zipdir, $zipfile);