PDF to Word
Turn a PDF into an editable .docx. Page 1 of the PDF starts page 1 of the Word file, at the
same size and orientation; headings, lists and tables come through as real Word structures, and
the Lao font is embedded so the file reads the same on any computer.
Lao is the reason this endpoint exists. Most converters copy the PDF’s hidden text layer, which for Lao is routinely broken — vowels and tone marks scattered, letters swapped. Here every page is read from its image, then checked:
- Typed pages are compared letter by letter with the PDF’s own text, and small misreadings are corrected from it.
- Scanned pages are read twice and the readings compared.
- Where a check fails, a stronger model reads the page again, shown both versions.
- A page that still cannot be read is placed in the Word file as a picture, so the document stays whole — and that page is not charged.
1. Upload the PDF
A PDF can be far larger than a request body may be, so it goes straight to storage.
/v1/docconvert/uploads API key JSON body
contentType * string | Always "application/pdf". |
size * number | File size in bytes. Up to 100 MB. |
The response carries uploadUrl (PUT the file there with content-type: application/pdf) and the sourceKey to use below.
2. Inspect (optional, free)
/v1/docconvert/inspect API key How many pages, whether they are typed or scanned, and the price — counted from the file itself, the same count the job is charged for.
{
"status": "success",
"pages": 100,
"kind": "digital",
"scannedPages": 0,
"maxPages": 300,
"tooManyPages": false,
"creditsPerPage": 1,
"credits": 100,
"affordable": true
}3. Convert
/v1/docconvert/jobs API key JSON body
sourceKey * string | The key returned by the upload step. |
fileName string | Original file name; names the Word file. |
face modern | looped | Lao font for the Word file. Default: the style the PDF itself uses (looped for Phetsarath / Saysettha). |
storageOption none | platform | byo | Where the source and result are kept. Default: none (the Word file is kept 24 hours). |
# 1. Get an upload URL, then PUT the PDF to it
curl -X POST https://ai-api.vanguardinitiative.com/v1/docconvert/uploads \
-H "authorization: Bearer $API_KEY" -H 'content-type: application/json' \
-d '{"contentType":"application/pdf","size":5242880}'
curl -X PUT "$UPLOAD_URL" -H 'content-type: application/pdf' --data-binary @report.pdf
# 2. (optional) Pages and price, before anything is spent
curl -X POST https://ai-api.vanguardinitiative.com/v1/docconvert/inspect \
-H "authorization: Bearer $API_KEY" -H 'content-type: application/json' \
-d '{"sourceKey":"'$SOURCE_KEY'"}'
# 3. Start the conversion
curl -X POST https://ai-api.vanguardinitiative.com/v1/docconvert/jobs \
-H "authorization: Bearer $API_KEY" -H 'content-type: application/json' \
-d '{"sourceKey":"'$SOURCE_KEY'","fileName":"report.pdf"}'
# 4. Poll, then download
curl https://ai-api.vanguardinitiative.com/v1/jobs/$JOB_ID -H "authorization: Bearer $API_KEY"
curl -o report.docx "https://ai-api.vanguardinitiative.com/v1/jobs/$JOB_ID/export?format=docx" \
-H "authorization: Bearer $API_KEY"Poll GET /v1/jobs/{id}. While it runs, progress counts pages read:
{
"status": "success",
"job": {
"id": "9a2b7c10-...",
"serviceId": "docconvert",
"status": "processing",
"progress": { "unit": "page", "done": 37, "total": 100 }
}
}When it succeeds, result is the quality report — how each page was checked, which pages are worth
a human look (flagged), and which were placed as pictures (imagePages).
{
"status": "success",
"job": {
"status": "success",
"exportFormats": ["docx"],
"result": {
"pages": 100,
"verified": 94,
"doubleRead": 0,
"reviewed": 6,
"singleRead": 0,
"imagePages": [],
"flagged": [{ "page": 41, "score": 0.972 }],
"corrected": 18,
"face": "looped",
"billedUnits": 100
}
}
}4. Download
/v1/jobs/{id}/export?format=docx API key Returns the Word file. The suggested file name is in the x-file-name header (percent-encoded —
names are often Lao).