PDF Text Conversion API Guide

Extract readable PDF text as HTML, plain text, Markdown, or JSON using uploads or public links for search, indexing, and document workflows.

Try the live demoView API details →

PDF Text Conversion API

Extract readable text from PDF documents and return it as HTML, plain text, Markdown, or a JSON string. Use the results for indexing, document search, and content workflows.

View API details or try the live demo.

Upload a PDF

Send one PDF up to 20 MiB and 100 pages. Use pdffile for uploads; file remains a compatible alias. Supply exactly one of pdffile, file, or file_url.

curl 'https://api.gugudata.io/v1/imagerecognition/pdf2format?appkey=YOUR_APPKEY' \
  -F 'type=markdown' \
  -F 'pdffile=@document.pdf'

Convert a PDF URL

curl 'https://api.gugudata.io/v1/imagerecognition/pdf2format?appkey=YOUR_APPKEY' \
  -F 'type=json' \
  -F 'file_url=https://storage.gugudata.io/pdf/demo.pdf'

The sample PDF can be downloaded before trying the request. Remote documents must be publicly accessible over HTTP or HTTPS.

Choose an output format

type Returned content
html A UTF-8 HTML document with numbered page sections and escaped text
text or txt Plain text, with pages separated by blank lines
markdown or md Text under numbered page headings
json A JSON string containing a pages array with page numbers and text

data.result is always a string, including when type=json. Parse that string separately to read the pages object:

const response = await fetch(endpoint, { method: 'POST', body: formData });
const payload = await response.json();
if (!response.ok || payload.dataStatus.statusCode !== 200) {
  throw new Error(payload.dataStatus.statusDescription);
}
const pages = JSON.parse(payload.data.result).pages;

HTML preserves page order, text, and line breaks. This API does not reconstruct complex layouts, extract images, or perform OCR on scanned pages. Empty pages retain their position; a document with no readable text is rejected. Output is limited to 20 MiB.

Demo and caching

The Demo performs a real HTML conversion of the public sample PDF and caches the result for 15 minutes. X-GuGuData-Demo-Mode is live or cached; X-GuGuData-Generated-At identifies when the result was generated.

Errors

HTTP status Meaning
400 Missing or conflicting input, invalid format, or unsupported URL
401 / 403 Authentication or access was denied
413 PDF exceeds 20 MiB or 100 pages
422 Invalid, encrypted, unreadable PDF, or output exceeds the limit
429 Request limit exceeded
502 Remote PDF download failed or conversion returned an invalid response
503 Conversion is temporarily unavailable

Check both the HTTP status and dataStatus.statusCode. Keep application keys on your server. Store returned content according to your application’s access and retention requirements.