Nodes/ComfyUI_Fill-Nodes/FL Text To PDF
ComfyUI Node

FL Text To PDF

Turn plain text into a paginated PDF

By filliptm·Created 3 years ago·Updated about 9 hours ago· 628
FL Text To PDF
    • PDF
    text
    page_sizeA4
    font_size12
    margin72
    titleGenerated Document

    Fill-Nodes' PDF section is a small, complete toolkit hiding inside a much larger pack of image, GPT, and video tools: load, merge, encrypt, extract text, extract images, convert to/from images, and this - the node that goes the other direction, turning plain text into a formatted PDF document from scratch. If a downstream step in your workflow (a caption dump, a log, a generated report) produces text and you want a shareable document out of it rather than a raw .txt file, this is that step.

    How it works

    It's ReportLab's canvas API doing the actual drawing - the node takes your text, wraps it to fit the page width, breaks it across as many pages as needed, and stamps a title on it. Unlike the merger or saver nodes elsewhere in this category, there's no upstream PDF object required to feed it; text goes straight in, a PDF object comes straight out, ready to chain into FL_PDFSaver or FL_PDFMerger.

    The inputs and outputs that matter

    • text - your source text, multiline. This is what actually gets typeset and paginated.
    • title (default "Generated Document") - the document's title, likely both stamped visually and set as PDF metadata.
    • page_size (A4 / Letter) - pick based on your audience; A4 for most of the world, Letter for US-conventional documents.
    • font_size (default 12, 6–36) and margin (default 72, 36–144, in points - 72pt margin is a standard 1-inch margin) - the two knobs that actually shape how dense the resulting document looks. Smaller margin and larger font_size fit less text per page; the node handles pagination automatically either way, so you don't need to pre-calculate page breaks yourself.

    Output is a single PDF object - the pack's in-memory carrier type, not a file. Wire it into FL_PDFSaver to actually write a file, or into FL_PDFMerger if you want to prepend/append this generated page to another document (a cover page in front of an image-derived PDF, say).

    How to install it

    ComfyUI Manager: search "Fill-Nodes", install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/filliptm/ComfyUI_Fill-Nodes
    pip install -r ComfyUI_Fill-Nodes/requirements.txt
    

    ReportLab is the dependency doing the real work here, bundled with everything else the pack's PDF nodes need (PyPDF2, PyMuPDF). Installing Fill-Nodes for just this one node still pulls in the pack's much larger footprint - image VFX libraries, API SDKs for the AI nodes, audio libraries - since it all ships as one install.

    Common issues & troubleshooting

    Output PDF looks empty or nearly empty. Check that text is actually wired to something producing content, not left on an empty default - this node has no placeholder text of its own to fall back on.

    Text is getting cut off oddly at page boundaries. That's the automatic pagination doing its job across a page-size boundary - if the break lands somewhere awkward, adjust margin or font_size slightly rather than trying to manually control where a page ends; there's no explicit page-break control exposed here.

    Special characters or non-Latin scripts render wrong. ReportLab's default font handling is basic-Latin-focused; if your text includes characters outside that range, they may not render as expected - this is a known limitation of the simple canvas approach rather than something this node's settings can fix.

    Category🏵️Fill Nodes/PDF

    Inputs (5)

    NameTypeDefaultDescription
    textSTRING
    page_sizeCOMBOA42 options: A4, Letter
    font_sizeINT126–36
    marginINT7236–144
    titleSTRINGGenerated Document

    Outputs (1)

    NameTypeDescription
    PDFPDF