60 lines
2.0 KiB
PHP
60 lines
2.0 KiB
PHP
<?php
|
|
class Xmerge extends MY_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
function test()
|
|
{
|
|
$rpts = [
|
|
"http://riau.aplikasi.web.id/birt/run?__report=report/onelab/lab/rpt_hasil_so_elmd_email.rptdesign&__format=pdf&username=Administrator&PID=166120&PLang=1&tm=1680169903247",
|
|
"http://riau.aplikasi.web.id/birt/run?__report=report/onelab/lab/rpt_hasil_so_elmd_email.rptdesign&__format=pdf&username=Administrator&PID=166637&PLang=1&tm=1680169868058",
|
|
"http://riau.aplikasi.web.id/birt/run?__report=report/onelab/lab/rpt_hasil_so_xray_email.rptdesign&__format=pdf&username=Administrator&PID=488824&PLang=1&tm=1680169820609",
|
|
"http://riau.aplikasi.web.id/birt/frameset?__report=report/onelab/lab/rpt_test_email.rptdesign&__format=pdf&username=Administrator&PID=486186&tm=1680169786824",
|
|
"http://devone.aplikasi.web.id/birt/frameset?__report=report/onelab/lab/rpt_attachment.rptdesign&__format=pdf&username=ADMIN&PID=131636&tm=1680066068969#"
|
|
];
|
|
$name = "Test-Merge-Report.pdf";
|
|
$this->merge($name, $rpts);
|
|
}
|
|
function merge($name, $rpts, $debug = "")
|
|
{
|
|
$output_file_name = $name;
|
|
$target = tempnam("/tmp", uniqid("target", true));
|
|
$merge_cmd = "/usr/bin/pdfunite";
|
|
$base_url = "http://localhost/";
|
|
$fnames_del = [];
|
|
foreach ($rpts as $r) {
|
|
$fname = tempnam("/tmp", uniqid("src", true));
|
|
$url = $r;
|
|
$rpt_data = file_get_contents($url);
|
|
if (strlen($rpt_data) > 0) {
|
|
file_put_contents($fname, $rpt_data);
|
|
$merge_cmd .= " $fname ";
|
|
}
|
|
$fnames_del[] = $fname;
|
|
}
|
|
$merge_cmd .= " $target";
|
|
if ($debug != "") {
|
|
echo $merge_cmd;
|
|
exit;
|
|
}
|
|
$output = [];
|
|
exec($merge_cmd, $output);
|
|
header("Content-type: application/pdf");
|
|
header(
|
|
'Content-Disposition: inline; filename="' .
|
|
$output_file_name .
|
|
'"'
|
|
);
|
|
echo file_get_contents($target);
|
|
foreach ($fnames_del as $fdel) {
|
|
unlink($fdel);
|
|
}
|
|
if (file_exists($target)) {
|
|
unlink($target);
|
|
}
|
|
exit;
|
|
}
|
|
}
|