本文整理汇总了PHP中mPDF::UseTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP mPDF::UseTemplate方法的具体用法?PHP mPDF::UseTemplate怎么用?PHP mPDF::UseTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mPDF
的用法示例。
在下文中一共展示了mPDF::UseTemplate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: merge
/**
* @param string $dest
* @param string[] $files
* @return bool true, falls min ein Quelldokument verwendbar war
*/
public static function merge($dest, $files)
{
Logging::info('Erzeuge ' . $dest);
//$dest = Files::validateFilename($dest);
$pdf = new \mPDF('de-DE', 'A4');
$pdf->SetImportUse();
$page = 0;
foreach ($files as $curFile) {
Logging::info('Eingangsdatei ' . $curFile);
if ($curFile == '') {
continue;
}
$pagecount = $pdf->SetSourceFile($curFile);
if ($page != 0) {
$pdf->AddPage();
}
for ($i = 1; $i <= $pagecount; $i++) {
$import_page = $pdf->ImportPage($i);
$pdf->UseTemplate($import_page);
if ($i < $pagecount) {
$pdf->AddPage();
}
}
$page++;
}
$pdf->Output($dest, 'F');
return $page > 0;
}
示例2: mergePdf
/**
* merge another pdf to current
* @param type $anotherPdfPath
* @return \Kohana_MPDF
*/
public function mergePdf($anotherPdfPath)
{
$this->checkMpdfInit();
$pagecount = $this->setSourceFile($anotherPdfPath);
for ($i = 1; $i <= $pagecount; $i++) {
$this->mpdf->AddPage();
$tplId = $this->mpdf->ImportPage($i);
$this->mpdf->UseTemplate($tplId);
$this->mpdf->WriteHTML();
}
return $this;
}
示例3: explodePDF
/**
* @param $path
* @param $print_portrait
* @param $print_paper_size
* @param $labels
* @return bool|string
*/
public function explodePDF($path, $print_portrait, $print_paper_size, $labels)
{
ini_set('memory_limit', '1024M');
if (!is_file($path)) {
return false;
}
$isPortrait = $print_portrait;
$paperSize = in_array($print_paper_size, ['A2', 'A3', 'A4', 'A5']) ? $print_paper_size : 'A4';
$pdfInfo = $this->pdfInfo($path);
if (!$pdfInfo) {
return false;
}
$pdfSize = array_map(function ($item) {
return trim((int) $item);
}, explode('x', $pdfInfo['Page size']));
$pdfSize['w'] = $pdfSize[0] * 0.75;
$pdfSize['h'] = $pdfSize[1] * 0.75;
$paperSizes = ['A2' => ['w' => 420, 'h' => 594], 'A3' => ['w' => 297, 'h' => 420], 'A4' => ['w' => 210, 'h' => 297], 'A5' => ['w' => 148, 'h' => 210]];
include dirname(__DIR__) . "/lib/mpdf/mpdf.php";
$mgl = 10;
$mgr = 10;
$mgt = 20 + 10;
$mgb = 5 + 10;
$mgh = 9;
$mgf = 9;
if ($isPortrait) {
$mgl = 20;
$mgr = 10;
$mgt = 5 + 10;
$mgb = 5 + 10;
$mgh = 9;
$mgf = 9;
}
$mpdf = new \mPDF('c', $paperSize . ($isPortrait ? '-P' : '-L'));
$mpdf->SetImportUse();
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetCompression(true);
//$mpdf->SetAutoPageBreak(true);
$mpdf->mirrorMargins = true;
$source = $mpdf->SetSourceFile($path);
$page_w = $isPortrait ? $paperSizes[$paperSize]['w'] : $paperSizes[$paperSize]['h'];
$page_h = $isPortrait ? $paperSizes[$paperSize]['h'] : $paperSizes[$paperSize]['w'];
$iter_w = ceil($pdfSize['w'] / $page_w / 2);
$iter_h = ceil($pdfSize['h'] / $page_h / 1);
$crop_x = 0;
$crop_y = 0;
$head_left = isset($labels['head_left']) ? $labels['head_left'] : '';
$head_center = isset($labels['head_center']) ? $labels['head_center'] : '';
$head_right = isset($labels['head_right']) ? $labels['head_right'] : '';
$footer_left = isset($labels['footer_left']) ? $labels['footer_left'] : '';
$footer_center = isset($labels['footer_center']) ? $labels['footer_center'] : '';
$footer_right = isset($labels['footer_right']) ? $labels['footer_right'] : '';
$header = '
<table width="100%" style="vertical-align: bottom; font-size: 12pt; font-weight: bold"><tr>
<td width="33%">' . $head_left . '</td>
<td width="33%" align="center">' . $head_center . '</td>
<td width="33%" style="text-align: right;">' . $head_right . '</td>
</tr></table>
';
$footer = '
<table width="100%" style="vertical-align: bottom; font-size: 12pt; font-weight: bold"><tr>
<td width="33%">' . $footer_left . '</td>
<td width="33%" align="center">' . $footer_center . '</td>
<td width="33%" style="text-align: right;">' . $footer_right . '</td>
</tr></table>
';
$mpdf->SetHTMLHeader($header);
$mpdf->SetHTMLHeader($header, 'E');
$mpdf->SetHTMLFooter($footer);
$mpdf->SetHTMLFooter($footer, 'E');
for ($i = 0; $i < $iter_w; $i++) {
if ($i > 0) {
$mpdf->AddPage();
}
// '', '', '', '', '', $mgl, $mgr, $mgt, $mgb, $mgh, $mgf
$tpl = $mpdf->ImportPage($source, $crop_x, $crop_y, $page_w - ($mgl + $mgr), $page_h - ($mgt + $mgb));
$mpdf->UseTemplate($tpl, $mgl, $mgt);
if ($iter_h > 2) {
$mpdf->AddPage();
$tpl = $mpdf->ImportPage($source, $crop_x, $crop_y, $page_w - ($mgl + $mgr), $page_h - ($mgt + $mgb));
$mpdf->UseTemplate($tpl, $mgl, $mgt);
}
$crop_x += $page_w - ($mgl + $mgr);
}
$mpdf->Output($path . 'gen.pdf', 'F');
return $path . 'gen.pdf';
}
示例4: iconv
$tormoz = str_replace("Combined", "Комбинированный", $tormoz);
$tormoz = str_replace("None", "Отстутствует", $tormoz);
include "mpdf50/mpdf.php";
for ($i = 1; $i < 27; $i++) {
if (empty($row['field' . $i])) {
$row['field' . $i] = iconv('WINDOWS-1251', 'UTF-8', 'ОТСУТСТВУЕТ');
}
}
$mpdf = new mPDF();
$mpdf->SetImportUse();
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetCompression(false);
// Add First page
$pagecount = $mpdf->SetSourceFile('2.pdf');
$tplIdx = $mpdf->ImportPage(1);
$mpdf->UseTemplate($tplIdx);
$html = '
<table border="0" class="startusq">
<tr>
<td></td>
<td></td>
<td></td>
<td>' . $rowzaw[3] . '</td>
<td>' . $rowzaw[4] . '</td>
<td>' . $rowzaw[5] . '</td>
<td>' . $rowzaw[6] . '</td>
<td>' . $rowzaw[7] . '</td>
<td>' . $rowzaw[8] . '</td>
<td>' . $rowzaw[9] . '</td>
<td>' . $rowzaw[10] . '</td>
<td>' . $rowzaw[11] . '</td>
示例5: array
}
if ($i % 2 == 1) {
$pp[] = array($p1, $i);
} else {
$pp[] = array($i, $p1);
}
}
return $pp;
}
$mpdf = new mPDF('', 'A4-L', '', '', 0, 0, 0, 0, 0, 0);
$mpdf->SetImportUse();
$ow = $mpdf->h;
$oh = $mpdf->w;
$pw = $mpdf->w / 2;
$ph = $mpdf->h;
$mpdf->SetDisplayMode('fullpage');
$pagecount = $mpdf->SetSourceFile('test.pdf');
$pp = GetBookletPages($pagecount);
foreach ($pp as $v) {
$mpdf->AddPage();
if ($v[0] > 0 && $v[0] <= $pagecount) {
$tplIdx = $mpdf->ImportPage($v[0], 0, 0, $ow, $oh);
$mpdf->UseTemplate($tplIdx, 0, 0, $pw, $ph);
}
if ($v[1] > 0 && $v[1] <= $pagecount) {
$tplIdx = $mpdf->ImportPage($v[1], 0, 0, $ow, $oh);
$mpdf->UseTemplate($tplIdx, $pw, 0, $pw, $ph);
}
}
$mpdf->Output();
exit;
示例6: mPDF
<?php
// required to load FPDI classes
require_once __DIR__ . '/../vendor/autoload.php';
$mpdf = new mPDF('', '', '', '', 15, 15, 57, 16, 9, 9);
$mpdf->SetImportUse();
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetCompression(false);
// Add First page
$pagecount = $mpdf->SetSourceFile('sample_basic.pdf');
$crop_x = 50;
$crop_y = 50;
$crop_w = 100;
$crop_h = 100;
$tplIdx = $mpdf->ImportPage(2, $crop_x, $crop_y, $crop_w, $crop_h);
$x = 50;
$y = 50;
$w = 100;
$h = 100;
$mpdf->UseTemplate($tplIdx, $x, $y, $w, $h);
$mpdf->Rect($x, $y, $w, $h);
$mpdf->Output('newpdf.pdf', 'I');
开发者ID:CarlosAyala,项目名称:midas-codeigniter-modulo-emergencias,代码行数:22,代码来源:example41_MPDFI_template.php
示例7: mpdf_output
//.........这里部分代码省略.........
if ($pdf_margin_header !== 0 && $pdf_margin_header == '') {
$pdf_margin_header = 9;
}
if ($pdf_margin_footer !== 0 && $pdf_margin_footer == '') {
$pdf_margin_footer = 9;
}
if (empty($pdf_html_header)) {
$pdf_html_header = false;
}
if (empty($pdf_html_footer)) {
$pdf_html_footer = false;
}
global $pdf_orientation;
if ($pdf_orientation == '') {
$pdf_orientation = 'P';
}
$cp = 'utf-8';
if (get_option('mpdf_code_page') != '') {
$cp = get_option('mpdf_code_page');
}
$mpdf = new mPDF($cp, 'A4', '', '', $pdf_margin_left, $pdf_margin_right, $pdf_margin_top, $pdf_margin_bottom, $pdf_margin_header, $pdf_margin_footer, $pdf_orientation);
$mpdf->SetUserRights();
$mpdf->title2annots = false;
//$mpdf->annotMargin = 12;
$mpdf->use_embeddedfonts_1252 = true;
// false is default
$mpdf->SetBasePath($templatePath);
//Set PDF Template if it's set
global $pdf_template_pdfpage;
global $pdf_template_pdfpage_page;
global $pdf_template_pdfdoc;
if (isset($pdf_template_pdfdoc) && $pdf_template_pdfdoc != '') {
$mpdf->SetImportUse();
$mpdf->SetDocTemplate($templatePath . $pdf_template_pdfdoc, true);
} else {
if (isset($pdf_template_pdfpage) && $pdf_template_pdfpage != '' && isset($pdf_template_pdfpage_page) && is_numeric($pdf_template_pdfpage_page)) {
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile($templatePath . $pdf_template_pdfpage);
if ($pdf_template_pdfpage_page < 1) {
$pdf_template_pdfpage_page = 1;
} else {
if ($pdf_template_pdfpage_page > $pagecount) {
$pdf_template_pdfpage_page = $pagecount;
}
}
$tplId = $mpdf->ImportPage($pdf_template_pdfpage_page);
$mpdf->UseTemplate($tplId);
}
}
$user_info = get_userdata($post->post_author);
$mpdf->SetAuthor($user_info->first_name . ' ' . $user_info->last_name . ' (' . $user_info->user_login . ')');
$mpdf->SetCreator('wp-mpdf');
//The Header and Footer
global $pdf_footer;
global $pdf_header;
$mpdf->startPageNums();
// Required for TOC use after AddPage(), and to use Headers and Footers
if ($pdf_html_header) {
$mpdf->SetHTMLHeader($pdf_header);
} else {
$mpdf->setHeader($pdf_header);
}
if ($pdf_html_footer) {
$mpdf->SetHTMLFooter($pdf_footer);
} else {
$mpdf->setFooter($pdf_footer);
}
if (get_option('mpdf_theme') != '' && file_exists($templatePath . get_option('mpdf_theme') . '.css')) {
//Read the StyleCSS
$tmpCSS = file_get_contents($templatePath . get_option('mpdf_theme') . '.css');
$mpdf->WriteHTML($tmpCSS, 1);
}
//My Filters
require_once dirname(__FILE__) . '/myfilters.inc.php';
$wp_content = mpdf_myfilters($wp_content);
if (get_option('mpdf_debug') == true) {
if (!is_dir(dirname(__FILE__) . '/debug/')) {
mkdir(dirname(__FILE__) . '/debug/');
}
file_put_contents(dirname(__FILE__) . '/debug/' . get_option('mpdf_theme') . '_' . $pdf_ofilename . '.html', $wp_content);
}
//die($wp_content);
$mpdf->WriteHTML($wp_content);
/**
* Allow to process the pdf by an 3th party plugin
*/
do_action('mpdf_output', $mpdf, $pdf_filename);
if (get_option('mpdf_caching') == true) {
file_put_contents(mpdf_getcachedir() . get_option('mpdf_theme') . '_' . $pdf_ofilename . '.cache', $post->post_modified_gmt);
$mpdf->Output(mpdf_getcachedir() . get_option('mpdf_theme') . '_' . $pdf_ofilename, 'F');
if ($outputToBrowser == true) {
$mpdf->Output($pdf_filename, 'I');
}
} else {
if ($outputToBrowser == true) {
$mpdf->Output($pdf_filename, 'I');
}
}
}
}
示例8: mPDF
require_once $path_fix . 'modules/PDFMaker/resources/mpdf/mpdf.php';
$export_pdf_format = $_REQUEST['export_pdf_format'];
$mpdf = new mPDF('utf-8', "{$export_pdf_format}", "", "", "5", "5", "0", "5", "5", "5");
$mpdf->keep_table_proportions = true;
$mpdf->SetAutoFont();
$filename = $_REQUEST['report_filename'];
$filename = html_entity_decode($filename, ENT_COMPAT, $default_charset);
$filename = $path_fix . $filename;
if (is_file($filename)) {
$mpdf->AddPage();
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile($filename);
if ($pagecount > 0) {
for ($i = 1; $i <= $pagecount; $i++) {
$tplId = $mpdf->ImportPage($i);
$mpdf->UseTemplate($tplId);
if ($i < $pagecount) {
$mpdf->AddPage();
}
}
}
if (file_exists($path_fix . $file_path) == true) {
$mpdf->AddPage('L');
$ch_image_html .= "<div style='width:100%;text-align:center;'><table class='rptTable' style='border:0px;padding:0px;margin:auto;width:80%;text-align:center;' cellpadding='5' cellspacing='0' align='center'>\n\t <tr>\n\t <td class='rpt4youGrpHead0' nowrap='' >";
$ch_image_html .= "<img src='{$site_URL}" . $file_path . "' />";
$ch_image_html .= "</td>\n\t </tr>\n\t </table></div>";
$mpdf->WriteHTML($ch_image_html);
}
$mpdf->Output($filename, 'F');
}
}
示例9: SinglePage
$y = $y1;
} else {
if ($i % 4 == 3) {
$x = $x1;
$y = $y2;
} else {
if ($i % 4 == 0) {
$x = $x2;
$y = $y2;
}
}
}
}
$tplIdx = $mpdf->ImportPage($i, 0, 0, $pw, $pph[$i]);
if ($align == 'T') {
$mpdf->UseTemplate($tplIdx, $x, $y, $pw, $pph[$i]);
} else {
$mpdf->UseTemplate($tplIdx, $x, $y + ($ph - $pph[$i]) / 2, $pw, $pph[$i]);
}
if ($border >= 0) {
$mpdf->Rect($x - $border, $y - $border, $pw + 2 * $border, $ph + 2 * $border);
}
}
$mpdf->Output();
exit;
//==============================================================
function SinglePage($html, $pw, $ph, $minK = 1, $inc = 0.1)
{
// returns height of page
global $mpdf;
$mpdf->AddPage('', '', '', '', '', '', $mpdf->w - $pw, '', $mpdf->h - $ph, 0, 0);
示例10: validar_planes
public function validar_planes($valoracion)
{
modules::run('general/is_logged', base_url().'index.php/usuarios/iniciar-sesion');
$this->load->helper('text');
$view['valoracion'] = $valoracion;
$val = str_replace('-', ' ', $valoracion);
$val = ucwords($val);
$val = str_replace(' ', '-', $val);
$where = array('ra.valoracion' => $val);
$view['plan_continuidad'] = $this->riesgos->get_allpcn($where);
$view['dptos'] = $this->general->get_table('departamento');
if($_POST)
{
$this->load->library('mpdf');
$post = $where = $_POST;
$pcn = $this->general->get_row('plan_continuidad',array('id_continuidad'=>$post['id_continuidad']),array('denominacion,pdf'));
$dpto = $this->general->get_row('departamento',array('departamento_id'=>$post['departamento_id']),array('nombre'));
$personal = $this->general->get_row('personal',array('id_personal'=>$post['id_personal']),array('nombre,cargo'));
$post['denominacion_pcn'] = $pcn->denominacion;
$post['nombre_dpto'] = $dpto->nombre;
$post['nombre_personal'] = $personal->cargo.': '.$personal->nombre;
$post['fecha_creacion'] = date('Y-m-d H:i:s');
if($this->general->insert('validacion_pcn',$post,$where))
{
$validacion = $this->general->get_result('validacion_pcn',array('id_continuidad'=>$post['id_continuidad']));
foreach($validacion as $key => $valid)
$ppl[] = '<li>'.$valid->nombre_personal.', el día '.date('d-m-Y',strtotime($valid->fecha_creacion)).'</li>';
$ppl_str = '<ul>'.implode('', $ppl).'</ul>';
$mpdf = new mPDF();
$mpdf->WriteHTML('<h1>Plan de Continuidad del Negocio VALIDADO</h1><p>El presente PCN fué revisado y validado por:<p>'.$ppl_str);
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile($pcn->pdf);
for($i=1;$i<=$pagecount;$i++)
{
$mpdf->AddPage();
$tplId = $mpdf->ImportPage($i);
$mpdf->UseTemplate($tplId);
}
unlink($pcn->pdf);
$mpdf->Output($pcn->pdf,'F');
$this->session->set_flashdata('alert_success','Plan de Continuidad del Negocio validado con éxito');
}else
$this->session->set_flashdata('alert_error','Hubo un error validando el PCN. O ya está validado por '.$personal->nombre);
redirect(site_url('index.php/continuidad/listado_pcn/'.$valoracion));
}
$breadcrumbs = array
(
base_url() => 'Inicio',
base_url().'index.php/continuidad' => 'Continuidad del Negocio',
base_url().'index.php/continuidad/seleccionar_listado' => 'Seleccionar Listado',
base_url().'index.php/continuidad/listado_pcn/'.$valoracion => 'Listado de PCN',
'#' => 'Validar PCN'
);
$view['breadcrumbs'] = breadcrumbs($breadcrumbs);
$this->utils->template($this->_list1(),'continuidad/continuidad/validar_pdf',$view,$this->title,'Validar PCN','two_level');
}
示例11: uploadfile
public function uploadfile()
{
$folder = isset($_GET['folder']) ? $_GET['folder'] : 'others';
$targetFolder = "/upload_file/{$folder}";
$prefix = time();
$setting = $this->general_model->get_email_from_setting();
$type = explode(",", $setting[0]['download_type']);
foreach ($type as $key => $value) {
$type[$key] = strtolower($value);
}
$userid = $_SESSION['user']['user_id'];
if (!empty($_FILES)) {
$_FILES["Filedata"]["name"] = str_replace(' ', '', $_FILES["Filedata"]["name"]);
$_FILES["Filedata"]["tmp_name"] = str_replace(' ', '', $_FILES["Filedata"]["tmp_name"]);
$uploaddatafile1 = md5($_FILES["Filedata"]["name"]);
$tempFile = $_FILES["Filedata"]["tmp_name"];
$targetPath = $_SERVER["DOCUMENT_ROOT"] . $targetFolder;
$targetFile = rtrim($targetPath, "/") . "/" . $_FILES["Filedata"]["name"];
$fileTypes = $type;
//array("zip","rar");
$fileParts = pathinfo($_FILES["Filedata"]["name"]);
if (in_array(strtolower($fileParts["extension"]), $fileTypes)) {
move_uploaded_file($tempFile, $targetFile);
if (isset($_GET['w'])) {
$w = $_GET['w'];
} else {
$w = 100;
}
if (isset($_GET['h'])) {
$h = $_GET['h'];
} else {
$h = 100;
}
$path_upload = "upload_file/{$folder}/" . $_FILES["Filedata"]["name"];
$root = dirname(dirname(dirname(__FILE__)));
$file = '/' . $path_upload;
//a reference to the file in reference to the current working directory.
// Process for image
$image_info = @getimagesize(base_url() . $path_upload);
if (!empty($image_info)) {
$image = true;
} else {
$image = false;
}
if ($image) {
if (!isset($_SESSION['fileuploadname'])) {
$_SESSION['fileuploadname'] = $_FILES["Filedata"]["name"];
$_SESSION['fileuploadhtml'] = '';
} else {
if (empty($_SESSION['fileuploadname'])) {
$_SESSION['fileuploadname'] = $_FILES["Filedata"]["name"];
$_SESSION['fileuploadhtml'] = '';
}
}
$_SESSION['fileuploadhtml'] .= '<img src="' . base_url() . $path_upload . '" style="width:850px;"/>';
echo "2";
exit;
}
include $root . "/mpdf/mpdf.php";
require_once $root . "/scribd.php";
$scribd_api_key = "766ydp7ellofhr7x027wl";
$scribd_secret = "sec-7zrz2fxxa2chak965tbp67npqw";
$scribd = new Scribd($scribd_api_key, $scribd_secret);
$doc_type = null;
$access = "private";
$rev_id = null;
$data = $scribd->upload($file, $doc_type, $access, $rev_id);
if (!empty($data)) {
$result = 0;
while ($result == 0) {
echo $result = $scribd->getDownloadLinks($data['doc_id']);
}
file_put_contents('/upload_file/files/c' . $uploaddatafile1 . ".pdf", fopen($result["download_link"], 'r'));
//file_put_contents( fopen($result["download_link"], 'r'));
$mpdf = new mPDF();
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile('/upload_file/files/r' . $uploaddatafile1 . ".pdf");
$tplId = $mpdf->ImportPage(1);
$mpdf->UseTemplate($tplId);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetWatermarkText(' ');
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->showWatermarkText = true;
$md5 = $uploaddatafile1;
$mpdf->Output('/upload_file/files/' . $md5 . '.pdf', '');
$mpdf->Thumbnail('/upload_file/files/' . $md5 . '.pdf', 1);
$mpdf->Output('/upload_file/files/' . $md5 . '.pdf', '');
unlink('/upload_file/files/c' . $uploaddatafile1 . ".pdf");
$im = new imagick();
$im->readimage('/upload_file/files/' . $md5 . '.pdf');
//$im->readimage('/upload_file/files/'.$md5.'.pdf');
$im->setImageCompressionQuality(0);
$im->setImageFormat('jpeg');
$im->writeImage('/upload_file/images/r' . $md5 . '.jpg');
$this->db->set('id', $userid);
$this->db->set('fullpdf', '/upload_file/files/r' . $uploaddatafile1 . '.pdf');
$this->db->set('pdf', '/upload_file/files/' . $md5 . '.pdf');
$this->db->set('image', '/upload_file/images/r' . $md5 . '.jpg');
$this->db->insert('scribe');
$im->clear();
//.........这里部分代码省略.........
示例12: process
public function process(Vtiger_Request $request)
{
$response = new Vtiger_Response();
$debug_fs = "";
$reportsDeleteDenied = array();
$ReportsTempDirectory = "test/ITS4YouReports/";
//$path_fix = "../../../";
$path_fix = "";
//$filename = $path_fix."test/ITS4YouReports/".$_REQUEST["filename"].".pdf";
$file_path = $_REQUEST["filepath"];
// "test/$filename.png"
if (is_writable($path_fix . $ReportsTempDirectory)) {
if (isset($_REQUEST["canvasData"]) && $_REQUEST["canvasData"] != "") {
$unencodedData = $_REQUEST["canvasData"];
file_put_contents($path_fix . $file_path, base64_decode($unencodedData));
}
if (isset($_REQUEST["mode"]) && $_REQUEST["mode"] == "download") {
if (file_exists($path_fix . 'modules/PDFMaker/resources/mpdf/mpdf.php')) {
require_once $path_fix . 'modules/PDFMaker/resources/mpdf/mpdf.php';
$export_pdf_format = $_REQUEST['export_pdf_format'];
$mpdf = new mPDF('utf-8', "{$export_pdf_format}", "", "", "5", "5", "0", "5", "5", "5");
$mpdf->keep_table_proportions = true;
$mpdf->SetAutoFont();
$filename = $ReportsTempDirectory . $_REQUEST['report_filename'];
$filename = html_entity_decode($filename, ENT_COMPAT, $default_charset);
$filename = $path_fix . $filename;
if (is_file($filename)) {
$mpdf->AddPage();
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile($filename);
if ($pagecount > 0) {
for ($i = 1; $i <= $pagecount; $i++) {
$tplId = $mpdf->ImportPage($i);
$mpdf->UseTemplate($tplId);
if ($i < $pagecount) {
$mpdf->AddPage();
}
}
}
if (file_exists($path_fix . $file_path) == true) {
$mpdf->AddPage('L');
$ch_image_html .= "<div style='width:100%;text-align:center;'><table class='rptTable' style='border:0px;padding:0px;margin:auto;width:80%;text-align:center;' cellpadding='5' cellspacing='0' align='center'>\n \t\t <tr>\n \t\t <td class='rpt4youGrpHead0' nowrap='' >";
$ch_image_html .= "<img src='{$site_URL}" . $file_path . "' />";
$ch_image_html .= "</td>\n \t\t </tr>\n \t\t </table></div>";
$mpdf->WriteHTML($ch_image_html);
}
//$mpdf->Output($filename,'F');
$mpdf->Output($_REQUEST['report_filename'], 'D');
}
}
}
}
//$response->setResult(array("done-P"));
//$response->emit();
}
示例13: writeByMpdf
private function writeByMpdf(){
$tmpfile = 'logs/temp_' . str_replace('/', '_', $this->invNO) . '.pdf';
$this->Output($tmpfile,'F');
include_once ('mpdf/mpdf.php');
$mpdf=new \mPDF('','','','',15,15,57,16,9,9);
$mpdf->SetImportUse();
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetCompression(false);
$pagecount = $mpdf->SetSourceFile($tmpfile);
for ($i=1; $i<=$pagecount; $i++) {
$tplIdx = $mpdf->ImportPage($i);
$mpdf->UseTemplate($tplIdx);
if ($i < $pagecount)
$pdf->AddPage($this->orientaion);
}
$mpdf->Output();
unlink($tmpfile);
// $newfile = $this->invNO . '.pdf';
// $mpdf->Output($newfile, 'I');
}