Scanned Documents
Extraction starts by pulling the text out of the PDF. A scan has no text in it, just an image of a page, so there is nothing to pull and the response comes back with almost every field missing. Nothing errors, which is what makes this confusing the first time.
Tell it the input is a scan:
curl -X POST https://cloud.unidoc.io/api/uniai/extract/invoice \
-H "X-API-KEY: $UNIDOC_LICENSE_API_KEY" \
-F "[email protected]" \
-F "is_scanned=true"With the flag set, each page is also rendered to an image and sent to the model alongside whatever text was found. The model reads the picture.
Telling the two apart
The quickest check is whether the file contains extractable text at all:
pdftotext scan.pdf - | wc -cA few bytes back means a scan. A born-digital invoice returns hundreds or thousands.
A PDF can also be a hybrid: a scan that has been through OCR already, so it carries a text layer of variable quality. Those extract without the flag, and how well depends entirely on how good the OCR was. If the output looks subtly wrong, garbled vendor names or transposed digits, the text layer is the suspect and the flag is the thing to try.
What the flag changes
| Default | is_scanned=true | |
|---|---|---|
| Text extraction | Yes | Yes |
| Page images sent | No | Yes, one per page |
| Works on a pure scan | No | Yes |
| Request cost | Pages | Pages |
| Latency | Lower | Higher, images are larger |
The flag adds to the request rather than replacing anything: text still goes, images go too, and the model uses the images to correct what the text says. On a document that has both a good text layer and clear scans, that combination is the most accurate option available.
It is not free in time. Rendering pages and uploading images is slower than sending text, so leave it off for born-digital documents.
Credits are counted per page either way, so the flag does not change the price.
Limitations
There is no auto-detection. Nothing inspects the PDF and turns this on for you, so a scan sent without the flag produces a sparse response and a successful status code. If you process a mixed stream of documents, check for a text layer yourself and set the flag accordingly.
Quality follows the scan. A skewed, low-resolution or heavily compressed page is hard for the model in the same way it is hard for a person. Straighten and rescan at a higher resolution if you control the source.
The three-page limit still applies, and scans are exactly the documents people most often have in long multi-page files.
Handwriting is not something to rely on. Printed text in a scan is the supported case; handwritten amounts or signatures may come through, may not, and will not be flagged as uncertain either way.
If you need OCR as a product rather than as an input to extraction, UniPDF has its own OCR guides and gives you the text to do what you like with.