paddle_ocr: Perform OCR on an image, PDF, or URL using PaddleOCR

View source: R/paddle_ocr.R

paddle_ocrR Documentation

Perform OCR on an image, PDF, or URL using PaddleOCR

Description

This is the main entry point for the PaddleOCR cloud API. Submit a local file (image or document) or a URL, and the function will handle job submission, polling, result retrieval, and file saving automatically.

Usage

paddle_ocr(
  file_path,
  output_dir = "output",
  token = "",
  job_url = "",
  model = "",
  use_doc_orientation_classify = FALSE,
  use_doc_unwarping = FALSE,
  use_chart_recognition = FALSE,
  poll_interval = 5,
  max_wait_seconds = 3600,
  timeout = 600
)

Arguments

file_path

A local file path or a URL (http:// or https://).

output_dir

Directory to save output Markdown and images (default: "output").

token

PaddleOCR API bearer token. If empty, reads from the PADDLE_OCR_TOKEN environment variable.

job_url

PaddleOCR API endpoint. Defaults to the official cloud URL.

model

Model name to use. Defaults to "PaddleOCR-VL-1.6".

use_doc_orientation_classify

Logical; enable document orientation classification.

use_doc_unwarping

Logical; enable document unwarping.

use_chart_recognition

Logical; enable chart/table recognition.

poll_interval

Seconds between status checks (default: 5).

max_wait_seconds

Maximum wait time for job completion (default: 3600).

timeout

HTTP request timeout in seconds (default: 600).

Value

A list with elements:

file_path

Input file path or URL.

job_id

The submitted job ID.

output_dir

Output directory path.

markdown_files

Paths to saved Markdown files.

page_count

Number of pages processed.

Examples

## Not run: 
# OCR a local image
result <- paddle_ocr("document.png")

# OCR a URL
result <- paddle_ocr("https://example.com/document.jpg")

# With custom options
result <- paddle_ocr(
  file_path = "table.png",
  use_chart_recognition = TRUE,
  output_dir = "my_output"
)

## End(Not run)

PaddleOCR documentation built on Aug. 30, 2026, 5:07 p.m.