Reads scanned PDFs and document photos with OCR and returns the text, a searchable PDF, or both.
Say it in your own words; the assistant finds this recipe by itself. Examples:
Read a scanned PDF or a photo of a document in ONE command (OCR with tesseract, tuned for speed): the text as Markdown or plain text, a searchable PDF (the scan with an invisible text layer, so it can be searched and copied), or both; English by default, Danish on request, one page or a range. Use for: this PDF is a scan and I need the text, make this scanned contract searchable, read the invoice photo, pull the text out of these scanned pages. Triggers: scan, scanned, OCR, image-only PDF, photo of a document, searchable PDF, tekstgenkendelse, scannet, læs scanningen.
python3 /skills/scan-to-text/scripts/scan.py <verb> IN OUT [--lang eng|dan|eng+dan] [--pages 1-3] [--dpi 150]
rasterises the pages with poppler and reads them with tesseract. Inputs are in /work/in
(PDF, PNG, JPG, TIFF), results in /work/out. Every verb prints one OK … line (pages, words,
seconds) or one ERROR … line.
| Need | Command |
|---|---|
| The text as Markdown (one heading per page) | scan.py text /work/in/scan.pdf /work/out/scan.md |
| Plain text instead | scan.py text /work/in/scan.pdf /work/out/scan.txt |
| A searchable PDF (looks the same, text layer underneath) | scan.py searchable /work/in/scan.pdf /work/out/scan-searchable.pdf |
| Both at once | scan.py both /work/in/scan.pdf /work/out/scan → scan.md + scan-searchable.pdf |
| Danish document | add --lang dan (or --lang eng+dan when both occur) |
| Only some pages | add --pages 1-3 (or --pages 2) |
| Is it a scan at all? | scan.py probe /work/in/file.pdf (says whether the PDF already has text; if it has, use pdftotext or office-convert instead) |
Speed: about 3.5 s per page at the default 150 dpi with one language; --dpi 200 for small
print, --lang eng+dan costs roughly a third more. Up to ~20 pages run directly with
sandbox_run; for longer scans use start_job with the same command and poll job_status.
Give the person the download link(s) from the OK line; do not paste whole pages into the chat
unless they asked for the text itself.
SKILL.mdgate.jsonscripts/__pycache__/scan.cpython-313.pycscripts/scan.pyWritten by Percerno, MIT licence.