本文整理汇总了PHP中mPDF::SetCompression方法的典型用法代码示例。如果您正苦于以下问题:PHP mPDF::SetCompression方法的具体用法?PHP mPDF::SetCompression怎么用?PHP mPDF::SetCompression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mPDF
的用法示例。
在下文中一共展示了mPDF::SetCompression方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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';
}
示例2: mPDF
}
$html12=file_get_contents(home_url().'/pdf12/?order_id='.$order_id);
$html13=file_get_contents(home_url().'/pdf13/?order_id='.$order_id);
$html14=file_get_contents(home_url().'/pdf14/?order_id='.$order_id);
//print_r($weight_range_new);
// mode, format, default_font_size, default_font, margin_left, margin_right,
// margin_top, margin_bottom, margin_header, margin_footer, orientation
//echo "after for loop";
$mpdf = new mPDF('UTF-8','A4-L');
$mpdf->defaultPagebreakType='clonebycss';
$mpdf->SetCompression(true);
$mpdf->useLang = true;
//$mpdf->use_kwt = true;
$css=file_get_contents(get_template_directory_uri().'-child/PDF_html/pdf_style.css');
//--------------------------------------------------, L , R , T , B ,
$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0, 'L');
$mpdf->WriteHTML($css,1);
$mpdf->WriteHTML(htmlspecialchars_decode($html1),2);
//file_put_contents($uppath1.'status.json',json_encode(array('current'=>'58','total'=>'100')));
$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0, 'L');
$mpdf->WriteHTML(htmlspecialchars_decode($html2));
$header3=__('<div style="padding:0px 0px 0px 0px;height:12mm;width:100%;background:#FFF;border:0;outline:none;margin:0;">
<div style="padding:1px 38.4px 0px 37px;">
示例3: iconv
$petrol = str_replace("None", "Без топлива", $petrol);
$tormoz = str_replace("Hydraulic", "Гидравлический", $row['field16']);
$tormoz = str_replace("Pneumatic", "Пневматический", $tormoz);
$tormoz = str_replace("Mechanical", "Механический", $tormoz);
$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>
示例4: pdf_file_creation
function pdf_file_creation($atts){
require_once 'mpdf/mpdf.php';
global $wpdb, $shopkeeper_theme_options;
try{
$site_logo = $shopkeeper_theme_options['light_transparent_header_logo']['url'];
//$order_id=$_REQUEST['order_id'];
//echo $order_id;
$order_id=$atts['order_id'];
$order_item_id=$atts['order_item_id'];
$billing_first_name = get_post_meta($order_id,'_billing_first_name',true);
$billing_last_name = get_post_meta($order_id,'_billing_last_name',true);
$billing_email = get_post_meta($order_id,'_billing_email',true);
$order=new WC_Order($order_id);
$items = $order->get_items();
$item_data=$items [array_keys($items)[0]];
$plan_id=$item_data['item_meta']['_product_id'][0];
$site_id=get_current_blog_id();
$plan_details=get_post($plan_id);
$plan_period=get_post_meta($plan_id,'plan_period',true);
$path = wp_upload_dir();
$pdfname='';
$order_details=$wpdb->get_results('select id,meals_per_day,no_of_weeks,regenerate,current_weight from up_user_nutrition_plans where order_id='.$order_id.' AND site_id='.$site_id);
$weight_range=$wpdb->get_results('select expected_weight from up_plan_logs where user_nutrition_plan_id=(select id from up_user_nutrition_plans where order_id='.$order_id.' AND site_id='.$site_id.')',ARRAY_N);
$no_of_weeks=$order_details[0]->no_of_weeks;
if(isset($order_details) && !empty($order_details)){
$plan_name=$items [array_keys($items)[0]]['name'];
$username="admin";
$password="upfit@123";
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n".
"Authorization: Basic " . base64_encode("$username:$password")
)
);
$context = stream_context_create($opts);
$html1=file_get_contents(home_url().'/pdf1/?order_id='.$order_id,false,$context);
$html2=file_get_contents(home_url().'/pdf2/?order_id='.$order_id,false,$context);
$html3=file_get_contents(home_url().'/pdf3/?order_id='.$order_id,false,$context);
//echo $html1;
for($i=1;$i<=$no_of_weeks;$i++){
$weight_range_new[$i]=$weight_range[$i-1][0];
// echo $weight_range_new[$i].'<br/>';
// echo "in for loop".$i;
$html4[$i]=file_get_contents(home_url().'/pdf4/?order_id='.$order_id.'&week_no='.$i,false,$context);
$html5[$i]=file_get_contents(home_url().'/pdf5/?order_id='.$order_id.'&week_no='.$i,false,$context);
$html6[$i]=file_get_contents(home_url().'/pdf6/?order_id='.$order_id.'&week_no='.$i,false,$context);
$html7[$i]=file_get_contents(home_url().'/pdf7/?order_id='.$order_id.'&week_no='.$i,false,$context);
$html8[$i]=file_get_contents(home_url().'/pdf8/?order_id='.$order_id.'&week_no='.$i,false,$context);
$html9[$i]=file_get_contents(home_url().'/pdf9/?order_id='.$order_id.'&week_no='.$i,false,$context);
$html10[$i]=file_get_contents(home_url().'/pdf10/?order_id='.$order_id.'&week_no='.$i,false,$context);
$html11[$i]=file_get_contents(home_url().'/shopping/?order_id='.$order_id.'&week_no='.$i,false,$context);
}
$html12=file_get_contents(home_url().'/pdf12/?order_id='.$order_id,false,$context);
$html13=file_get_contents(home_url().'/pdf13/?order_id='.$order_id,false,$context);
//$html14=file_get_contents(home_url().'/pdf14/?order_id='.$order_id);
// print_r($weight_range_new);
// mode, format, default_font_size, default_font, margin_left, margin_right,
// margin_top, margin_bottom, margin_header, margin_footer, orientation
//echo "after for loop";
$mpdf = new mPDF('UTF-8','A4-L');
$mpdf->defaultPagebreakType='clonebycss';
$mpdf->SetCompression(true);
$mpdf->useLang = true;
//$mpdf->use_kwt = true;
$css=file_get_contents(get_template_directory_uri().'-child/PDF_html/pdf_style.css',false,$context);
//--------------------------------------------------, L , R , T , B ,
$mpdf->AddPage('UTF-8','A4-L', 0, 'avenir', 0,0,0,0,0,0, 'L');
$mpdf->WriteHTML($css,1);
//.........这里部分代码省略.........
示例5: 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');
}