How to add page numbers to PDF programmatically?

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 any solution on VeryPDF? If adding page numbers to PDF by VB, there would be much better.

Answer: According to your needs, maybe you can have a free trial of this software: VeryPDF PDF Stamp SDK, by which you can stamp PDF on large documents from VB easily. By this software, you can also allows you to integrate PDF Stamp application into your own programs. This SDK version also allows you to call it from  .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 on homepage, in the following part, let us check how to use this software.

Step 1. Free download PDF Stamp COM

  • This software can work under all the Windows system both of 32-bit and 64-bit. When downloading finishes, there will be an zip file, please extract it to some folder then you can call it from MS Dos Windows.
  • When you use this software, please refer to the usage and examples. There are code templates of calling it from VB, VC and others.

Step 2. Add page number to PDF.

  • When you add page number to PDF, you may need to use the following parameters:
  • \p      Current page number Maybe “Page \p” equal ”Page 3”
    \P±n Current page number ± a specified value   Maybe "Page \p+1" equal "Page 4"
    \c       Total page number   Maybe “Total \c” equal  “Total 3”

    And add page number to where:
    1   Stamps on the Top-Left of the page. (default)
    2   Stamps on the Top-Center of the page.
    3   Stamps on the Top-Right of the page.
    4   Stamps on the Right-Center of the page.
    5   Stamps on the Right-Bottom of the page.
    6   Stamps on the Bottom-Center of the page.
    7   Stamps on the Left-Bottom of the page.
    8   Stamps on the Left-Center of the page.
    9   Stamps on the Center of the page.

Now let us check one example of calling this software from VB, please have a check.

Private Sub StampIntoPDFFile()
   Dim szInputPDFFile As String
   Dim szOutPDFFile As String
   Dim id As Long
   Dim code As Long
   Dim NullString As String

    szInputPDFFile = "C:\example.pdf"
    szOutPDFFile = "C:\out.pdf"
   page = 1
   strStamp = ""
   id = veryOpen(szInputPDFFile, szOutPDFFile)
  If (id > 0) Then
       pagecount = veryGetFunction(id, Very_Get_PdfPageCount,
                             0, 0, 0, 0)

Do While page <= pagecount
     strStamp = strStamp + "*"
      code = verySetFunction(id, Very_Set_Range,
      page, 1, 0, 0
     code = veryAddText(id, 6, "page " & strStamp,
     RGB(255, 200, 100), 0, 0, 0, 0, 0, 0, 0,                   
     NullString, 0, 0, NullString, 0)
     page = page +
veryClose (id)
End If

End Sub

During the using, if you have any question, please contact us as soon as possible.

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

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!