How to add page numbers to PDF from PHP code?

Question:If you've got a large document (500 pages+) in PDF and want to add page numbers, does anyone know how to do this? Is there ant solution on VeryPDF? I hope the process could be done under PHP code.

Answer: According to your needs, maybe you can have a free trial of this software:VeryPDF PDF Stamp SDK, by which you can add page number to PDF from 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.  This software is a professional tool of stamping PDF by various stamps. And page number could be considered as one of stamp on PDF. Please check more detail information of this software on homepage, in the following part, I will show you how to use this software.

Step 1. Free download PDF Stamp COM

  • This COM version is a 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.
  • When downloading finishes, there will be a zip file. Please extract it to some folder then you can check related elements, help document and code templates of calling this software together with other application.

Step 2. Add page number to PDF from PHP code.

  • When you use this software, please refer to the usage and examples. As this software either can be used as command line software, here are some parameters and examples for your reference:
  • \P±Current page number±a specified value Maybe "Page \p+1" equal  "Page 4"
    \c Total page number Maybe "Total \c" equal  "Total 3"
    pdfstamp.exe -PDF "example.pdf" -o "opacity.pdf" -AT "VeryPDF Opacity" -FT "Arial" -P9 -FS100 -opacity50 -C#FF0000 -AI logo.jpg -opacity80 -P2 -AL -LW30 -opacity30 -LINEEX 100,100,200,200
    pdfstamp.exe -PDFs "C:\*.pdf" -o "C:\out" -AT "An example for '-PDFS' parameter" -p2 -fs32 -c2666666 -mtb200
    Please check more usage and example on User Manual.

  • Here is one code of calling this software from PHP code, please have a check.
  • <?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;
    ?>

    Now let us check the stamping effect from the following snapshot. During the using, if you have any question, please contact us as soon as possible.

    stamped PDF
                             Add page number to PDF.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

This entry was posted in PDF Stamp and tagged . Bookmark the permalink.

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!