pdf_to_markdown_with_paddle: Convert a PDF to Markdown via PaddleOCR

View source: R/pdf.R

pdf_to_markdown_with_paddleR Documentation

Convert a PDF to Markdown via PaddleOCR

Description

Renders PDF pages to images one by one, then submits them for OCR using the PaddleOCR cloud API. Pages are processed in streaming batches: once batch_trigger pages are rendered, OCR begins while rendering continues.

Usage

pdf_to_markdown_with_paddle(
  pdf_path,
  output_dir = NULL,
  combined_markdown = TRUE,
  dpi = 300,
  batch_trigger = 3,
  workers = 1,
  resume = TRUE,
  token = "",
  job_url = "",
  model = "",
  use_doc_orientation_classify = FALSE,
  use_doc_unwarping = FALSE,
  use_chart_recognition = FALSE,
  poll_interval = 5,
  max_wait_seconds = 1800,
  timeout = 600,
  ...
)

Arguments

pdf_path

Path to the PDF file.

output_dir

Output directory. If NULL, defaults to "<pdf_name>_paddle_output" next to the PDF.

combined_markdown

Logical; if TRUE (default), combine all page Markdown into a single file.

dpi

Image resolution for rendering (default: 300).

batch_trigger

Number of pages to render before starting OCR (default: 3).

workers

Maximum number of OCR jobs submitted concurrently (default: 1). OCR runs concurrently on the PaddleOCR service; result polling remains local and sequential.

resume

Logical; reuse rendered page images, completed Markdown files, and submitted job IDs from an interrupted run (default: TRUE).

token

PaddleOCR API token.

job_url

PaddleOCR API endpoint.

model

Model name.

use_doc_orientation_classify

Logical; enable orientation classification.

use_doc_unwarping

Logical; enable document unwarping.

use_chart_recognition

Logical; enable chart recognition.

poll_interval

Polling interval in seconds.

max_wait_seconds

Maximum wait time per job.

timeout

HTTP timeout.

...

Ignored (for future compatibility).

Details

Requires the pdftools package.

Value

A list with PDF path, image paths, Markdown file paths, combined Markdown path and text, and output directory.

Examples

## Not run: 
result <- pdf_to_markdown_with_paddle("document.pdf")
cat(result$combined_markdown_text)

## End(Not run)

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