php图片水印添加,word同一页加多个水印

php给pdf加上水印环境php5.5.12fpdi-1.5.2fpdf-1.7原理利用fpdi来加载已知pdf文件php图片水印添加,用fpdf对pdf进行操作

注意事项免费php图片水印添加的fpdi只支持处理pdf1.4及以下版本php图片水印添加,1.5以上就需要用到FPDI PDF-Parser插件

php图片水印添加,word同一页加多个水印

使用 *** fpdi-1.5.2fpdf-1.71.文字水印 word.php

<?php

require_once('./fpdf/fpdf.php');require_once('./fpdi/fpdi.php');

//word_watermark$pdf = new FPDI();

// get the page countpageCount =pageCount=pdf->setSourceFile('more.pdf');

// iterate through all pagesfor (pageNo = 1;pageNo=1;pageNo <= pageCount;pageCount;pageNo++){ // import a page templateId =templateId=pdf->importPage($pageNo);

// get the size of the imported page size =size=pdf->getTemplateSize($templateId);

// create a page (landscape or portrait depending on the imported page size) if (size['w'] >size[′w′]>size['h']) pdf->AddPage('L', array(pdf−>AddPage(′L′,array(size['w'], $size['h'])); else pdf->AddPage('P', array(pdf−>AddPage(′P′,array(size['w'], $size['h']));

php图片水印添加,word同一页加多个水印

// use the imported page pdf->useTemplate(pdf−>useTemplate(templateId);

$pdf->SetFont('Arial','B','12'); // sign with current date $pdf->SetXY(0, 0); // you should keep testing untill you find out correct x,y values $pdf->Write(7, date('Y-m-d'));

}$pdf->Output('word.pdf');

2.图片水印 pic.php

<?php

require_once('./fpdf/fpdf.php');require_once('./fpdi/fpdi.php');

//pic_watermark$pdf = new FPDI();// get the page countpageCount =pageCount=pdf->setSourceFile('more.pdf');

// iterate through all pagesfor (pageNo = 1;pageNo=1;pageNo <= pageCount;pageCount;pageNo++){ // import a page templateId =templateId=pdf->importPage($pageNo);

// get the size of the imported page size =size=pdf->getTemplateSize($templateId);

// create a page (landscape or portrait depending on the imported page size) if (size['w'] >size[′w′]>size['h']) pdf->AddPage('L', array(pdf−>AddPage(′L′,array(size['w'], $size['h'])); else pdf->AddPage('P', array(pdf−>AddPage(′P′,array(size['w'], $size['h']));

// use the imported page pdf->useTemplate(pdf−>useTemplate(templateId);

// Place the graphics $pdf->image("test.png", 75, 85, 50);

}$pdf->Output('pic.pdf');3.项目地址

pdf_watermark

https://github.com/laiyuxiang/pdf_watermark/

发布于 2024-07-23 17:07:35
收藏
分享
海报
0 条评论
42
目录

    0 条评论

    本站已关闭游客评论,请登录或者注册后再评论吧~