public static function pdfForceView($file_full_path, $title) {
self::clean_before_output();
if(!is_readable($file_full_path)){
return false;
}
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-type: application/pdf');
$filename = trim($title).'.pdf';
if(strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE') !== false){
$filename = rawurlencode($filename);
}
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file_full_path));
header('Accept-Ranges: bytes');
readfile($file_full_path);
}
用header是最簡單的。復雜的建議用 mpdf ,對中文的支持也很友好,也支持js.
Ⅱ PHP使用Mpdf生成PDF,windows下可以正常使用,但是到了linux上面 生成的就是空白頁面。求解決!!!
八成是某些函數寫的兼容性不夠好,要仔細檢查,linux系統下對語法要求是非常嚴謹的
Ⅲ html長按二維碼保存圖片
想要保存二維碼圖片,除了長按還可以截圖,截圖更方便
Ⅳ PHP生成PDF,用什麼類庫好
tcpdf,絕對好用
Ⅳ PHP MPDF庫贏得問題,怎麼解決
首先引入pdf擴展
然後下面這些方法 組合著用,就跟拼頁面一樣就可以啦,差什麼放什麼?不知道的結合下擴展文檔或者試一下,不難的!
pdf->SetFont();
pdf->Cell();
pdf->writeHTML();
pdf->Image( 'foot.png');
pdf->AddPage();
pdf->output();
Ⅵ 如何讓html2fpdf 支持中文
終於找到一款在FPDF和HTML2FPDF源碼基礎上開發的一套開源程序,作者很給力。基本解決了中文(以及日語、韓語及東南亞和全球語言)亂碼的問題,在Windows/Linux開發環境下測試可用,不需要安裝別的組件支持,是沒有VPS和獨立伺服器的網站開發者的福音。
不多說,源碼名稱是MPDF,官方地址是:http://www.mpdf1.com/ 已經更新到5.6版。
到官網下載,解壓到網站目錄下,使用。
?View Code PHP
[php] view plain print?
<?php
include('mpdf.php');
$mpdf=new mPDF('UTF-8','A4','','',15,15,44,15);
$mpdf->useAdobeCJK = true;
$mpdf->SetAutoFont(AUTOFONT_ALL);
$mpdf->SetDisplayMode('fullpage');
//$mpdf->watermark_font = 'GB';
//$mpdf->SetWatermarkText('中國水印',0.1);
$url = 'http://www.5eyi.com/';
$strContent = <a target="_blank" href="http://www.php.net/file_get_contents">file_get_contents</a>($url);
//print_r($strContent);die;
$mpdf->showWatermarkText = true;
$mpdf->SetAutoFont();
//$mpdf->SetHTMLHeader( '頭部' );
//$mpdf->SetHTMLFooter( '底部' );
$mpdf->WriteHTML($strContent);
$mpdf->Output('ss.pdf');
//$mpdf->Output('tmp.pdf',true);
//$mpdf->Output('tmp.pdf','d');
//$mpdf->Output();
<a target="_blank" href="http://www.php.net/exit">exit</a>;
?>
PASS:需要注意的是,PHP文件要是UTF-8。不用心情天空貼出的代碼,自己寫時出現方格亂碼時,可以在config.php $this->useAdobeCJK = false;修改成true或者必須標註:$mpdf->useAdobeCJK = true; 官方有文檔,可以自己摸索。