Nodes/ComfyUI PDF Nodes/Get PDF Page Count #️⃣📄
ComfyUI Node

Get PDF Page Count #️⃣📄

A one-number utility node, and why you'd bother

By orion4d·Created about a year ago·Updated about a year ago· 1
Get PDF Page Count #️⃣📄
  • pdf_pages
  • INT

Get PDF Page Count #️⃣📄 is the simplest node in the ComfyUI PDF Nodes pack: you feed it a PDF_PAGES wire and it gives you back one INT - the number of pages in that list. That's the whole job. There are no settings, no dropdowns, nothing to get wrong.

Why you'd reach for it

The honest answer is that you might not need it most of the time. PDFLoad already outputs page_count on its own, so for the most common case - "how many pages is this document?" - you can just read that number directly and skip this node entirely. Where PDFGetPageCount earns its keep is anywhere the page list has been changed since it was loaded:

  • After a PDFMerge, when you want to know how many pages the combined document has.
  • After Rotate PDF Pages, when nothing else has told you the count changed.
  • After Select Page & Extract Text, when you've cut a list down to a single page and want to confirm it.

Think of it as a probe: it turns whatever PDF_PAGES list is flowing through the graph into a number you can wire into logic. That's the real use case - ComfyUI has no built-in way to inspect a custom type, so this is your window into what a list actually contains.

Mechanism

It's dead simple under the hood. The node just does len(pdf_pages) on the list of pypdf page objects and returns the count. No file I/O, no parsing, no cost worth mentioning. The only edge case is an empty input - a failed PDFLoad returns an empty list, and this node dutifully reports 0, which is often your first clue that something upstream went wrong. The author's own console log makes this clear: PDFGetPageCountNode: PDF has N pages.

The input that matters

  • pdf_pages (PDF_PAGES) - the only input, and the only wire that works here is another node from this pack. Load, Merge, Rotate, or Select all produce compatible lists.

Output is a single INT, ready to plug into anything that takes an integer - a comparison, a math node, a text template, or a conditional that decides whether to process further. Since the count is 1-indexed in human terms and the indices inside the pack are 0-indexed, remember: 10 pages means valid page indices run 0–9. The count node doesn't care; it's your downstream nodes that do.

Install and wrap-up

Same pack, same install as everything else here - ComfyUI Manager, search "ComfyUI PDF Nodes", or:

cd ComfyUI/custom_nodes/
git clone https://github.com/orion4d/ComfyUI_pdf_nodes.git
cd ComfyUI_pdf_nodes && pip install -r requirements.txt

Restart, and it lives under the PDF category. This node needs nothing but pypdf - no PyMuPDF, no Pillow, no models. It's the kind of utility node that feels pointless until the moment you need a count mid-graph and realize you'd rather wire an INT than eyeball a document. Then it's exactly the tool you want: one input, one number, no surprises.

CategoryPDF

Inputs (1)

NameTypeDefaultDescription
pdf_pagesPDF_PAGES

Outputs (1)

NameTypeDescription
INTINT