Question:I need a way to count the number of pages of a PDF in PHP. I've done a bit of Goggling and the only things I've found either utilize shell/bash scripts, perl, or other languages, but I need something in native PHP, VB .NET, MS Visual Basic, Borland Delphi, or others. Are there any libraries or examples of how to do this on VeryPDF?
Answer: According to your needs, maybe you can have a free trial of this software: VeryPDF Advanced PDF Tools SDK. By this SDK version, you can in PHP, VB .NET, MS Visual Basic, Borland Delphi, or others. This software can help you edit PDF description, PDF custom description, PDF OpenAction options, PDF page view options, PDF metadata contents, and so on. Please check more functions of this software on homepage, in the following part, let us check how to use this software.
- There are two license types of this software: server version and developer license. By the server version, you can install this software under the whole sever. By the developer version, you can you can integrate the corresponding SOFTWARE into your developed software and redistribute it with royalty-free. If the SOFTWARE contains source codes, you have the right to modify and reuse the codes under the Developer License.
- When downloading finishes, there will be a zip file. Please extract it to some folder then you can call it from PHP or others computer language according to your needs.
Step 2. Count PDF page number
- For showing counting PDF page number effect, I will by command line from MS Dos Window to have a check. Page count result will be shown at the bottom of MS Dos Windows. Meanwhile, by this software, you can get all the basic information of added PDF like I showed in the following snapshot.
Here I show one example of calling this software from VB, VC++.
VB Example 2:
Private Sub VBCOMTest_Click()
Dim nRet As Long
Dim strCmd As String
strCmd = "pdftools.exe" & " -x ""0 0 612 792"" -j ""612 792 true"""
strCmd = strCmd & " -$ XXXXXXXXXXXXXXX"
strCmd = strCmd & " -i C:\test.pdf"
strCmd = strCmd & " -o C:\_test.pdf"
Set PDFToolsCOM = CreateObject("PDFTools.PDFToolsCOM")
nRet = PDFToolsCOM.com_VeryPDF_PDFTools(strCmd)
Set PDFToolsCOM = Nothing
__declspec(dllexport) int WINAPI VeryPDF_PDFTools(LPCTSTR lpCommand);
char *lpLicenseKey = "XXXXXXXXXXXXXX";
sprintf(szCommandLine,"pdftools.exe \"-$\" \"%s\" -x \"0 0 612 792\" -j \"612 792 true\" -i \"%s\" -o \"%s\"",
lpLicenseKey, "C:\\test.pdf", "C:\\_test.pdf");
int nRet = VeryPDF_PDFTools(szCommandLine);
During the using, if you have any question, please contact us as soon as possible.