0CodeKit icon

0CodeKit

A toolbox of no-code utilities

PDF → Count PDF Pages

AI-generated

Overview

The Count PDF Pages operation in the "PDF" resource of this custom n8n node allows you to determine the number of pages in a PDF document. You can provide the PDF either as a URL or as binary data from a previous workflow step. This is useful for automating document processing tasks, such as validating document length, splitting PDFs, or preparing reports based on page count.

Practical examples:

  • Automatically reject PDF uploads that exceed a certain page limit.
  • Route documents with more than X pages to a different workflow branch.
  • Generate summaries or logs of incoming PDF files by their page count.

Properties

Name Meaning
URL or Binary Data Choose how to provide the PDF:
- URL: Supply a direct link to the PDF file.
- Binary Data: Use binary data from a previous node.
URL The web address (URL) of the PDF file to analyze. Required if "URL or Binary Data" is set to "URL".
Binary Data The name of the binary property containing the PDF data. Required if "URL or Binary Data" is set to "Binary Data".

Output

The output will be a JSON object containing the result of the page count operation. While the exact field names depend on the API response, you can expect a structure similar to:

{
  "pages": 5
}
  • pages: The total number of pages detected in the provided PDF.

If an error occurs and "Continue On Fail" is enabled, the output may include:

{
  "error": "Error message"
}

Dependencies

  • External Service: Requires access to the CodeKit API (as indicated by the required codeKitApi credential).
  • n8n Configuration: Ensure the codeKitApi credential is configured in your n8n instance.

Troubleshooting

Common issues:

  • Invalid URL: If the provided URL does not point directly to a valid PDF, the operation may fail.
  • Missing Binary Data: If "Binary Data" is selected but no binary property is provided, the node will throw an error.
  • API Key Issues: If the codeKitApi credential is missing or invalid, requests will fail.

Common error messages:

  • "error": "Request failed with status code 401" – Check your API credentials.
  • "error": "Invalid PDF file" – Ensure the file at the URL or in the binary property is a valid PDF.
  • "error": "No binary data property found" – Make sure the correct binary property name is specified.

Links and References

Discussion