Skip to main content

Count PDF Pages

Controlled node

Overview

The Count PDF Pages node analyzes a PDF document from your Intellectible Library and returns the total number of pages it contains. This is useful for workflow logic that needs to process documents differently based on their length, or for reporting and validation purposes.

When triggered, the node reads the specified PDF file, calculates the page count, and outputs the result as a number. If the file cannot be processed or the project context is invalid, it returns an error object instead.

Inputs

InputTypeDescriptionDefault
RunEventFires when the node starts running.-
FileFileSourceA reference to a PDF file in your Intellectible Library. Accepts a single file object or an array (uses the first element if an array is provided).-

Outputs

OutputTypeDescription
DoneEventFires when the node has finished processing the PDF.
CountDataThe number of pages in the PDF as a number. Returns an error object {error: 'message'} if the operation fails (e.g., invalid file, no project ID, or unsupported format).

Runtime Behavior

When the Run event is triggered, the node performs the following actions:

  1. Validation: Checks that a valid file input is provided and that the workflow has a valid project context (runtimeProjectId).
  2. Processing: Calls the internal PDF parsing service to analyze the document and extract the page count.
  3. Output: Sets the count output to the integer value of pages found, then fires the done event.

If the input file is an array, the node automatically uses the first element. If the file cannot be parsed or the project ID is missing, the count output will contain an error object with a descriptive message instead of a number.

Example

Basic Page Count Check

A simple workflow that counts pages in a PDF and displays the result:

  1. Add a Start node to trigger the workflow.
  2. Connect the Start node's fired event to the Count PDF Pages node's run input.
  3. Select a PDF file from your Library in the node's panel UI.
  4. Connect the Count PDF Pages node's done event to a Show node (or any node that accepts the count data).
  5. Connect the count output to the Show node's value input to display the page number.

This setup will display the total number of pages when the workflow runs, allowing you to verify document length before processing.