How to add an overlay/stamp to a PDF file in PHP?

Question:Does anyone know how to programmatically add a overlay or stamp to a PDF file in PHP? So far the best I've come up with is calling the some library with the exec command line but I'd prefer an actual PHP method if one exists. Is there any better solution on VeryPDF?

Answer: According to your needs, maybe you can have a free trial of this software: VeryPDF PDF Stamp SDK, which is a really software developing toolkit. By it you can call this software from PHP code easily. It is an multi-functional tool for programmers to stamp PDF via stamping image to PDF, stamping text to PDF, or stamping graphics to PDF and process secondary development in various program platforms.  And you can use this software toolkit together with any programming language like C#, VB .NET, J# via .NET, Java via JNI, MS Visual Basic, Borland Delphi, MS Office products such as Access and C++ via COM, C and C++ via native C. Please check more information of this software on homepage, in the following part, let us check how to use this software.

Step 1. Free download PDF Stamp COM

  • When downloading finishes, it is an zip file, please extract it to some folder then you can check related document, executable file and others.
  • When you use this software, please note all variables must be preceded by the slash (\) character. If the \ character is missing, the variable name will appear in the stamped text. If you want to use the \ character in a stamp it must be listed in the stamp file as \\.

Step 2. Add and overlay/stamp to PDF in PHP.

  • When you stamp PDF from PHP code, please refer to the following code template:
  • <?php
        $PdfStamp =new COM("PDFStampOCX.CPDFStamp") or die("Cannot start PDFStampOCX");
        PdfStamp.veryRegEx("XXXXXXXXXXXXXXXXX")
        $id = oTest.veryOpenEx("C:\test.pdf", "C:\out.pdf")
         If ($id > 0)
      {

            $code = PdfStamp.veryAddTextEx($id, 3, "Demo Watermark", 0,                
                          0, 0, 0, 0, 0, 0, 300, "", 0, 0, "", 0)
            $code = PdfStamp.veryAddTextEx($id, 6, "Copyright                
                          verypdf.com, Inc.", RGB(255, 200, 100), 0, 0, 0, 0,                
                           0, 0, 0, "", 0, 0, "", 0)
            $code = PdfStamp.veryAddTextEx($id, 9, "www.verypdf.com\n                
                          Demo", 255, 0, 0, 0, -45, 0, 1, 200, "", 48, 0, "", 0)

            PdfStamp.veryCloseEx ($id)
           }
         $PdfStamp = null;
        ?>

By the above code template, you can add text watermark and specify color, position and others. If you need to know more parameters and code template, please go to VeryPDF PDF Stamp SDK User Manual. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)
How to add an overlay/stamp to a PDF file in PHP?, 10.0 out of 10 based on 1 rating

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!