您的位置 首页 php

php如何给pdf加上文字水印和图片水印

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

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

使用方法
fpdi-1.5.2
fpdf-1.7
1.文字水印 word.php

<?php

require_once(‘./fpdf/fpdf.php’);
require_once(‘./fpdi/fpdi.php’);


//word_watermark
$pdf = new FPDI();

// get the page count
pageCount =
pageCount =pdf->setSourceFile(‘more.pdf’);

// iterate through all pages
for (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);


$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 count
pageCount =
pageCount =pdf->setSourceFile(‘more.pdf’);

// iterate through all pages
for (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

文章来源:智云一二三科技

文章标题:php如何给pdf加上文字水印和图片水印

文章地址:https://www.zhihuclub.com/79197.shtml

关于作者: 智云科技

热门文章

评论已关闭

37条评论

  1. This immediately struck me, since I did not know much about Mauritius and wanted to know why it kept appearing

  2. , erythromycin, ketoconazole 200 mg, and itraconazole 200 mg If you have a medical emergency, call your doctor immediately

  3. For maximal effects, regular daily use for 6 months may be required to see reduced hair loss It is your healthcare provider who can determine if this medicine can offer benefits

  4. Niba ibi bibaye, ugomba rero gukoresha tamoxifen cyangwa arimidex. Today is CD 13 and one of my kits unlocked so I used it this AM.

  5. Inhibition of alphaglucosidase by aqueous extracts of some potent antidiabetic medicinal herbs.

  6. To a flask containing 4 3 tert butyldimethylsilyl oxy propyl 2 isopropylpyridin 3 amine Int 10c, 2

  7. fought back, Гў Results with individual agents were assessed based on trial design, size, follow up, and safety

  8. Malonyl and methylmalonyl extender units were found to be equivalent substrates for chain elongation

  9. In postmenopausal women, toremifene 60 mg daily is an effective and safe treatment of advanced ER positive or ER unknown breast cancer

  10. The women in the study were randomly selected to take either a placebo pill or tamoxifen for five years levitra how to taper a medrol dose pack Life already sounds far from normal for Cound, who gave up her job as a cycling photographer in South Africa to join Froome in Europe last year

  11. PDAC tumors resected from KPT mice were examined for evidence of tumor fibrosis and molecular markers of ductal cell phenotype

  12. Created on 3 16 2012 As mentioned earlier, many other disorders can result in a false positive nontreponemal test

  13. Physician nodded and said, I see, A small mercenary group that can give Adele five thousand gold coins is very interesting Hemic and Lymphatic eosinophilia, thrombocythemia, coagulation time increased, lymphocytosis, and thrombocytopenia

  14. Mommy misses you every day A propensity matched comparison of pleurodesis or tunneled pleural catheter in patients undergoing diagnostic thoracoscopy for malignancy

  15. They can, however, improve your cardiovascular health and reduce your risk of heart disease and stroke

  16. For this, we used the tamoxifen inducible Rosa26 Cre ERT2 27 system that was bred into conditional Zeb1 fl fl; Zeb2 fl fl 28 and compound Zeb1 fl fl; Zeb2 fl fl backgrounds Fig 4A

  17. After initial recruitment, follicles entering the growth phase enlarge, both by proliferation and differentiation of granulosa cells and an increase in the size of the oocyte

  18. At this time, he apple cider vinegar counter blood pressure medication heard will turmeric lower your blood pressure the order, and the dagger in his hand quickly slashed apple cider vinegar counter blood pressure medication his wrist gov does not provide legal notice to the public or judicial notice to the courts

  19. 6 Chloro 1, 1 dioxo 1, 2 dihydro 1lambda 6 benzo 1, 2, 4 thiadiazine 7 sulfonic acid amide 6 chloro 7 sulfamoyl 2H 1, 2, 4 benzothiadiazine 1, 1 dioxide Chlorothiazid Chlorothiazide Chlorothiazidum

  20. These observations suggested that systemically elevated levels of IL 23 could promote enthesitis by acting on a IL 23r positive cell population present in the enthesis

  21. PYRAZOLESULFONAMIDES AS ANTITUMOR AGENTS METHODS OF PREPARING SUBSTITUTED INDANES SOLID DISPERSIONS AND PHARMACEUTICAL COMPOSITIONS COMPRISING A SUBSTITUTED INDANE AND METHODS FOR THE PREPARATION AND USE THEREOF CD73 INHIBITORS AND USES THEREOF COMPOSITIONS AND METHODS FOR INHIBITING CD73

  22. The possibility of hypotensive effects with ALTACE ramipril capsules can be minimized by either discontinuing the diuretic or increasing the salt intake prior to initiation of treatment with ALTACE ramipril capsules

  23. In contrast to most current evidence based on the assessment of a single potassium measurement, this study is based on truly longitudinal data with repeated potassium measurements I ve also read about Brazil nuts, pineapple and pomegranate juice

网站地图