Ai knowledge and logicHelpers

transcribe_pdf

Extract text from a PDF URL, including OCR for scanned pages.

transcribe_pdf(url: str) -> str

Downloads a PDF from a public HTTP or HTTPS URL and returns its readable text. Octocom processes the document with OCR, so the helper works with both normal PDFs that contain selectable text and image-only scanned PDFs.

The returned string uses Markdown where the document service can recover useful structure such as headings, lists, and tables. Visual layout, illustrations, and the exact position of text on a page are not preserved.


Parameters

NameTypeDescription
urlstrA public HTTP or HTTPS URL that serves a PDF

Returns

str - the extracted, Markdown-formatted text.


Example: let a bot read an assembly manual

Create a Python action with a pdfUrl argument:

def execute_action(context):
    pdf_url = context["args"]["pdfUrl"]
    text = transcribe_pdf(pdf_url)

    return {
        "source": pdf_url,
        "text": text,
    }

The action can now receive a product's manual URL, extract the instructions on demand, and return them to the bot as tool context.

PDF transcription calls Octocom's document-processing service and can take several seconds, especially for scans. If the same PDF is likely to be read repeatedly, cache the result in the Organization Store.

The URL must be publicly reachable. Localhost, private-network, file, and other non-HTTP(S) URLs are rejected. Password-protected or corrupt PDFs may not be readable.

On this page