欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php填充pdf模板數(shù)據(jù) php生成pdf文檔

如何使用php修改pdf中的內(nèi)容,并且保證格式不亂

客戶端上傳pdf改為docx,然后通過phpword中模板替換變量的方法去替換,最后在服務(wù)器端用libreoffice對docx進(jìn)行PDF的轉(zhuǎn)換,這樣勉強(qiáng)能達(dá)到效果,具體的內(nèi)容你可以參考一下這篇文章對你應(yīng)該會(huì)有幫助

創(chuàng)新互聯(lián)長期為上1000+客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為貢嘎企業(yè)提供專業(yè)的網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì),貢嘎網(wǎng)站改版等技術(shù)服務(wù)。擁有十載豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。

php處理PDF的擴(kuò)展庫如何使用?

使用附件的文件里面的字體fonts,直接解壓到tcpdf文件夾下的fonts下,然后使 用$pdf-SetFont("stsongstdlight", "", 12);

就是用stsongstdlight這個(gè)字體,就可以顯示出來簡體、繁體中文了

注意:要顯示繁體字,只需將輸入法設(shè)為繁體即可

注意:

如果:

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

那么:

頁面記得也設(shè)為utf-8

輸入文字:

單行文本

Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='', $stretch=0)

Cell(寬, 高, 內(nèi)容, 邊框, 是否換行, 文字對齊, 文字底色,連接, 變寬)

多行文本

MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)

MultiCell(寬, 高, 內(nèi)容, 邊框,文字對齊, 文字底色, 是否換行, x坐標(biāo), y坐標(biāo), 變高, 變寬, 是否支持html, 自動(dòng)填充, 最大高度)

html文字

setHtmlLinksStyle($color=array(0,0,255), $fontstyle='U');

setHtmlLinksStyle(顏色默認(rèn)藍(lán)色, U有下劃線);

addHtmlLink($url, $name, $fill=0, $firstline=false, $color='', $style=-1);

addHtmlLink(超鏈接地址, 顯示文字, 是否有底色, $firstline=false, $color='', $style=-1);

換行

Ln($h='', $cell=false);

Ln(行數(shù), 是否cell);

加密

SetProtection($permissions=array(), $user_pass='', $owner_pass=null);

例如:

$pdf-SetProtection(array('print','modify','copy','annot-forms'), '854230');

圖片背景

Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border);

注意:把圖片放語句放在前面,并且使用絕對坐標(biāo)定位,即可做背景。

輸出pdf

$pdf-Output(doc.pdf', 'I');/* 默認(rèn)是I:在瀏覽器中打開,D:下載,F(xiàn):在服務(wù)器生成pdf ,S:只返回pdf的字符串,個(gè)人感覺無實(shí)在意義 */

如何使用PHP創(chuàng)建和修改PDF文檔

示例一:使用PHP生成一個(gè)簡單的PDF文檔

以下為引用的內(nèi)容:

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');

// create new PDF document

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information

$pdf-SetCreator(PDF_CREATOR);

$pdf-SetAuthor('Nicola Asuni');

$pdf-SetTitle('TCPDF Example 002');

$pdf-SetSubject('TCPDF Tutorial');

$pdf-SetKeywords('TCPDF, PDF, example, test, guide');

// remove default header/footer

$pdf-setPrintHeader(false);

$pdf-setPrintFooter(false);

// set default monospaced font

$pdf-SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins

$pdf-SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);

//set auto page breaks

$pdf-SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor

$pdf-setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings

$pdf-setLanguageArray($l);

// ---------------------------------------------------------

// set font

$pdf-SetFont('times', 'BI', 20);

// add a page

$pdf-AddPage();

// print a line using Cell()

$pdf-Cell(0, 10, 'Example 002', 1, 1, 'C');

// ---------------------------------------------------------

//Close and output PDF document

$pdf-Output('example_002.pdf', 'I');

?

使用PHP修改PDF文檔

下面我們討論如何使用PHP修改PDF文檔。假設(shè)我們需要將一張圖片通過PHP程序加入到PDF中,示例代碼如下:

示例二:使用PHP在PDF中增加一張圖片

以下為引用的內(nèi)容:

require_once('../config/lang/eng.php');

require_once('../tcpdf.php');

// create new PDF document

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information

$pdf-SetCreator(PDF_CREATOR);

$pdf-SetAuthor('Nicola Asuni');

$pdf-SetTitle('TCPDF Example 009');

$pdf-SetSubject('TCPDF Tutorial');

$pdf-SetKeywords('TCPDF, PDF, example, test, guide');

// set default header data

$pdf-SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// set header and footer fonts

$pdf-setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));

$pdf-setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font

$pdf-SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins

$pdf-SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);

$pdf-SetHeaderMargin(PDF_MARGIN_HEADER);

$pdf-SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks

$pdf-SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor

$pdf-setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings

$pdf-setLanguageArray($l);

// ---------------------------------------------------------

// add a page

$pdf-AddPage();

// set JPEG quality

$pdf-setJPEGQuality(75);

// Image example

$pdf-Image('../images/image_demo.jpg', 50, 50, 100, 150, '', '', '', true, 150);

// ---------------------------------------------------------

//Close and output PDF document

$pdf-Output('example_009.pdf', 'I');

?

本文題目:php填充pdf模板數(shù)據(jù) php生成pdf文檔
本文來源:http://chinadenli.net/article38/hijssp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)定制網(wǎng)站標(biāo)簽優(yōu)化網(wǎng)站維護(hù)電子商務(wù)網(wǎng)站導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司