Document To Text icon

Document To Text

Converts documents to text using Azure Open AI

Document To Text

AI-generated

Summary

Convert a binary document (PDF) to text by rendering each page as an image and using the Azure Open AI model to transcribe the content, preserving original formatting including images and tables described in text form.

Inputs

  • documentBinary (required) — The document to convert to text, provided in binary format encoded as a base64 string.
  • modelName (required) — The name of the Azure Open AI model (deployment) to use for text extraction (e.g., gpt-4, gpt-35-turbo).
  • systemPrompt (required) — The system prompt to guide the AI model's behavior, instructing it to output the PDF content verbatim including text-based descriptions of images and tables as they appear in the document.
  • scale — Rendering zoom factor (approximately DPI) used when converting PDF pages to images; default is 1.6.
  • temperature — Sampling temperature controlling randomness of the Azure Open AI model's output; default is 0.2.
  • maxParallelRequests — Maximum number of parallel requests sent to the Azure Open AI API when processing pages; default is 1.

Output shape

a single JSON object with two fields: 'output' containing the full extracted text of the document including descriptions of images and tables, and 'pages' indicating the number of pages processed.

The operation processes each PDF page individually by rendering it as an image and sending it to the Azure Open AI chat completion API with the system prompt. Text is returned concatenated for all pages. If the PDF has zero pages, an error will be thrown. The output does not summarize but reproduces the content verbatim in text form, maintaining inline image descriptions as requested by the prompt.

Discussion