简体   繁体   中英

Adding a “watermark” on a PDF with PDFlib

sorry for not providing any sourcecode. So I am having PDF files (already made) and a website where I offer them for download (I am oversimplifying here) anyway, what I want to do is, when someone clicks on them, I want with PHP and PDFlib insert a watermark into them with the date and the time. How is that possible?

I have searched the web, but I did not find any sample code and since I have never used PDFLib in my life, I am not even sure where to start.

Just point me into the direction or ignore, no need to give me negative points :-)

check out http://www.pdflib.com/pdflib-cookbook/pdf-import/stamp-pages/ which place a stamp across the page to all imported PDF pages.

For you case, you just have to adjust the

p.fit_textline("PRELIMINARY", 50, 50, "font=" + font +
   " fontsize=1 textrendering=1 boxsize={500 700} stamp=ul2lr" +
   " strokecolor=red strokewidth=2");

with the data and the position you need. For details about the fit_textline() options, check out the PDFlib API reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM