-
Notifications
You must be signed in to change notification settings - Fork 3
/
getpdf.php
41 lines (33 loc) · 1.28 KB
/
getpdf.php
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
/**
* Feed Browser pdf of documnet in default english language
*
* @author Vítězslav Dvořák <[email protected]>
*/
require_once '../vendor/autoload.php';
$oPage = new \Ease\WebPage();
\Ease\Shared::instanced()->loadConfig(dirname(__DIR__).'/tests/client.json',true);
$embed = $oPage->getRequestValue('embed');
$id = $oPage->getRequestValue('id');
$evidence = $oPage->getRequestValue('evidence');
$lang = $oPage->getRequestValue('lang');
$document = new \AbraFlexi\RO(is_numeric($id) ? intval($id) : $id,
['evidence' => $evidence]);
if (!is_null($document->getMyKey())) {
$documentBody = $document->getInFormat('pdf',null, empty($lang) ? 'en' : $lang );
if ($embed != 'true') {
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename='.$document->getEvidence().'_'.$document.'.pdf');
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
} else {
header('Content-Type: application/pdf');
}
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.strlen($documentBody));
echo $documentBody;
} else {
die(_('Wrong call'));
}