Count Pages of PDF Document


counts the number of pages in a given PDF file


  • Uri of PDF file via Intent.putDataAndType() (should point to a file located on the SD card)


  • number of pages via Intent.getExtras().getInt(“PAGES”) (the number is zero if a problem occurred)
  • Uri of PDF file via Intent.putDataAndType() (Uri of PDF file, mirrored for convenience)


public void startCountPagesOfPdfDocument() {
    Intent intent = new Intent("com.acadoid.pdfview.action.COUNT_PAGES"); 
    intent.setData(dataUri); // PDF file Uri 
    if (intent.resolveActivity(getPackageManager()) != null) { 
      startActivityForResult(intent, REQUEST_CODE);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) { 
      int pages = data.getIntExtra(PAGES);
      // handle result

Example intent filter

<activity ...>
        <action android:name="com.acadoid.pdfview.action.COUNT_PAGES" />
        <category android:name="android.intent.category.DEFAULT" />

Apps Providing an Implementation

Search on Github

Search on Google Play, AppBrain, Amazon App store or similar (not yet available - please make this happen!)

For Specification Writers

Edit on Github