BCL easyConverter SDK Word
easyConverter SDK Usermanual
PDF-to-Word Programming API  |  Download Free Trial  |  Contact Us to Purchase

NumberOfPages Property

Get the total number of pages from the input PDF.

int get_NumberOfPages(string InputFileName, string Password)
Function get_NumberOfPages(InputFileName As String, Password As String) As Integer
def getNumberOfPages(self, InputFileName, Password)
int getNumberOfPages(String InputFileName, String Password) throws PDF2WordException
function getNumberOfPages($InputFileName, $Password)
BclWdhrError GetNumberOfPages(BclPDF2Word * pPdf2Word, const wchar_t * InputFileName, const wchar_t * Password, int * pResult);
Function NumberOfPages(InputFileName As String, [Password] As Variant) As Long

Not applicable.

Parameters

InputFileName

Input PDF file.

Password (optional)

Password to open the PDF document, if any.

Exception Handling

Please refer to the list of return exceptions.

Example Usage

using BCL.easyConverter.Word;
...
PDF2Word pdf2word = new PDF2Word();
try
{
   int numPages = pdf2word.get_NumberOfPages(@"c:\temp\input.pdf", "");
   Console.WriteLine(numPages);
}
catch(PDF2WordException ex)
{
   Console.WriteLine(ex.Message);
}
finally
{
   pdf2word.Dispose();
}
Imports BCL.easyConverter.Word
...
Dim pdf2word As New PDF2Word()
Dim numPages As Integer
Try
   numPages = pdf2word.get_NumberOfPages("c:\test\input.pdf", "")
   System.Console.WriteLine(numPages)
Catch ex As PDF2WordException
   System.Console.WriteLine(ex.Message)
Finally
   pdf2word.Dispose()
End Try
import PDF2Word
pdf2word = PDF2Word.PDF2Word()
try:
   numPages = pdf2word.getNumberOfPages("c:\\test\\input.pdf", "")
   print(numPages)
except PDF2Word.PDF2WordException as ex:
   print(ex)
PDF2Word pdf2word = new PDF2Word();
try
{
   int numPages = pdf2word.getNumberOfPages("c:\\temp\\input.pdf", "", "", 0, -1);
   System.out.println(numPages);
}
catch(PDF2WordException e)
{
   System.out.println(e);
}
finally
{
   pdf2word.dispose();
}
<?php
require("PDF2Word.php");
$pdf2word = new BCL\easyConverter\Word\PDF2Word();
try
{
   $numPages = $pdf2word->getNumberOfPages("c:\\test\\input.pdf", "");
   echo "Number of pages: ", $numPages, "\n";
}
catch(BCL\easyConverter\Word\PDF2WordException $ex)
{
   echo $ex->getMessage(), "\n";
}
?>
#include <stdio.h>
#include <windows.h>
#include "easyConverter.h"

int main()
{
   HMODULE hPdf2WordDll = LoadLibraryW(L"C:\\Program Files\\BCL Technologies\\easyConverter SDK 5\\Rtf\\easyConverter.dll");
   if(!hPdf2WordDll)
   {
      printf("easyConverter could not be loaded.\n");
      return 1;
   }
   else
   {
      int numPages = 0;
      BclWdhrError error;
      BclPDF2Word* pPdf2Word = CreatePDF2Word(hPdf2WordDll);
      if(!pPdf2Word)
      {
         printf("easyConverter could not be initialized.\n");
         FreeLibrary(hPdf2WordDll);
         return 1;
      }
      error = pPdf2Word->GetNumberOfPages(pPdf2Word, L"c:\\test\\input.pdf", L"", &numPages);
      if(error)
      {
         printf("Conversion failed with error %d.\n", error);
         FreeLibrary(hPdf2WordDll);
         return 1;
      }
      else
         printf("Number of pages: %d\n", numPages);
      pPdf2Word->Dispose(pPdf2Word);
      FreeLibrary(hPdf2WordDll);
      return 0;
   }
}
oConverter = CreateObject("EasyConverter.PDF2Word.5")
nPages = oConverter.NumberOfPages(inFileName)

Not applicable.