glyphwise ocr

Documentation

User guide

Glyphwise OCR reads text from scanned documents, photos of pages and PDFs, and returns plain text, structured JSON with word positions, or a searchable PDF. It runs locally; nothing is sent anywhere.

What is in this folder

filepurpose
glyphwise.exe (Linux, macOS: glyphwise)command-line reader
glyphwise-server.exe (glyphwise-server)local HTTP service
glyphwise.dll (libglyphwise.so, libglyphwise.dylib) + include/glyphwise.hC API for use from other programs
models/line.bin + line.bin.lmrecognition model and its language model (keep them together)
EULA.mdthe end-user licence agreement that governs your use of Glyphwise
LICENSE, THIRD_PARTY_NOTICES.md, DATA_NOTICES.mdcopyright notice and third-party notices
glyphwise.licyour licence file, if it was delivered with the package (see below)

Supported inputs: PDF (text layers are read directly; scanned pages are recognized), TIFF (multi-page), PNG, JPEG, JPEG 2000, JBIG2, GIF, BMP, PNM.

Linux and macOS

The packages for Linux (x64, glibc 2.35 or newer) and macOS (12 or newer; one universal build for Apple silicon and Intel) hold the same programs without the .exe ending. The examples below use Windows paths; on Linux and macOS write ./glyphwise models/line.bin scan.pdf, with forward slashes.

  • macOS: the programs are not yet notarized by Apple, so the first start is blocked as "unidentified developer". Clear the download flag once, in the unpacked folder: xattr -dr com.apple.quarantine .
  • GPU: --gpu uses CUDA on Linux with an NVIDIA driver, or OpenCL where an OpenCL driver is installed. On macOS, recognition runs on the CPU (all cores).
  • C library: link against libglyphwise.so / libglyphwise.dylib and keep it next to your program or on the library path (LD_LIBRARY_PATH, or an rpath of @loader_path on macOS).
  • Licence file: next to the glyphwise program, or in ~/.config/glyphwise/glyphwise.lic.

Licence file

Glyphwise is unlocked by a licence file (glyphwise.lic) that you receive with your purchase. Save it, unchanged, in one of these places; the programs look for it in this order:

  1. the file named with --license FILE on the command line;
  2. the file named by the GLYPHWISE_LICENSE environment variable;
  3. glyphwise.lic in the same folder as glyphwise.exe / glyphwise-server.exe (for the C API: the folder of your program);
  4. %APPDATA%\Glyphwise\glyphwise.lic (Linux/macOS: ~/.config/glyphwise/glyphwise.lic).

glyphwise --license-info shows which licence is in use, what it covers and when it expires. The check is done on your computer; Glyphwise never contacts a server. The file is plain text and may be opened, but any change to it makes it invalid. A licence lists the parts it covers: ocr (the glyphwise command line), server (the HTTP service) and sdk (the C API).

Without a valid licence the programs run in evaluation mode and say so: glyphwise reads at most 3 pages per run, glyphwise-server returns at most 3 pages per request and stops answering after 25 requests until it is restarted, and the C API returns at most 3 pages per call and stops after 25 calls per process. Recognition quality is the same as in the licensed product.

Command line

glyphwise models\line.bin scan.pdf                          plain text to the console
glyphwise models\line.bin page.png --text page.txt          plain text to a file
glyphwise models\line.bin page.png --json page.json         words with positions and confidence
glyphwise models\line.bin a.tif b.png --pdf searchable.pdf  scans -> one searchable PDF
glyphwise models\line.bin scans --out-dir out --formats pdf,txt   one PDF and text file per scan
glyphwise models\line.bin scan.tif --hocr scan.hocr         hOCR (XHTML) for digitization tools
glyphwise models\line.bin scan.tif --alto scan.xml          ALTO v4 XML for library/archive systems
glyphwise models\line.bin scan.tif --review check.tsv       low-confidence words to proof-read
glyphwise models\line.bin report.pdf --xlsx tables.xlsx     tables to Excel, one sheet per table (--csv for CSV)
glyphwise models\line.bin letter.tif --docx letter.docx     editable Word document
glyphwise models\line.bin form.png --fields fields.csv      form fields, ticked boxes and barcodes
glyphwise models\line.bin a.tif --pdf a.pdf --pdf-image mrc small searchable PDF (sharp text, light background)
glyphwise models\line.bin notes.tif --words names.txt       prefer your own names and terms
glyphwise models\line.bin scan.pdf --force-ocr              recognize a PDF even if it has a text layer
glyphwise models\line.bin brief.pdf --lang fr               French language model (--lang list shows all)
glyphwise models\line.bin scan.pdf --gpu                    use an NVIDIA (CUDA) or OpenCL GPU if present
glyphwise models\line.bin mixed.pdf --lang auto           pick the language per page
glyphwise models\line.bin invoice.pdf --fields inv.csv     invoice number, dates, totals and line items
glyphwise models\line.bin --watch in --out-dir out          hot folder: read every file that arrives
glyphwise models\line.bin claim.pdf --redact all --pdf out.pdf   black out e-mails, phone, card and ID numbers

Several files can be given at once; they are processed in parallel. A folder means every supported file in it, and wildcards such as scans\*.tif work in every shell. --out-dir DIR writes one file per input and format, named after the input (--formats picks any of pdf, txt, json, hocr, alto, docx, xlsx, csv, fields; default txt). --pdf-dpi (default 300) sets the physical page size the scans are placed at in the PDF; set it to the scanning resolution if known.

PDFs protected only against printing, copying or editing (they open without a password) are read like any other PDF. A PDF that needs a password to open is refused with a message saying so.

Searchable PDF

Searchable PDFs are PDF/A-2u files (for archiving; every character is searchable as Unicode) and tagged PDF/UA files (accessible): screen readers get the text in reading order as headings, paragraphs and tables with header cells, skip running headers, footers and page numbers, and read it in the document's language (--lang, else the detected language, else English). The title is the input's file name. --pdf-image chooses how the page images are stored:

--pdf-imagePages lookSize
lossless (default)exactly like the scanlargest
jpeg or jpeg:QUALITYlike the scan, slight blursmaller on noisy or photographed pages
mrcsharp black text on a softened background; pictures keptsmall
bwblack and white onlysmallest

The HTTP service takes ?format=pdf with &pdf_image= and &pdf_dpi=; the desktop window has the same choice next to the PDF output.

Word documents

--docx FILE writes an editable Word document: the page size, paragraphs in reading order (words broken at the end of a line are joined again), headings, font sizes, alignment, bold words, two-column pages and tables. It suits letters, reports and articles. Forms are not laid out like the original: their text and tables follow one another. Italic is not detected. Checkboxes become Word checkboxes (ticked or not, as on the page) that can be clicked. Running headers, footers and page numbers are left out of the body text (in the JSON output those lines carry "role": "header" or "footer"). Also --formats docx, ?format=docx on the HTTP service, and Word document in the desktop window.

Form fields, checkboxes and barcodes

--fields FILE writes a CSV of what a form holds: label and value pairs ("Name: Ann Smith", or a label with its value further along the line or just below it), checkboxes with their label and whether they are ticked, and barcodes and QR codes with their content. Columns: source, page, kind (text, checkbox or barcode), key, value, confidence. The JSON output lists the same per page under fields, checkboxes and barcodes, with their positions. Barcodes read: QR codes, Data Matrix, PDF417, Code 128, Code 39, EAN-13, UPC-A and EAN-8, also on turned pages. Checkboxes in a grid whose labels are column headings get the text next to them, not the heading. Also ?format=fields, format 5 of the C API, and Form fields in the desktop window.

Invoices and receipts get fields of kind invoice: vendor, vendor_tax_id, invoice_number, invoice_date, due_date, po_number, currency, subtotal, tax_rate, tax, total, iban, the line items (item_1_description, item_1_quantity, item_1_unit_price, item_1_amount, ...) and amounts_check: ok when the subtotal plus tax equals the total and the items add up, mismatch when they do not (worth a look). Dates come out as YYYY-MM-DD and amounts as plain numbers (1204.28). Labels are recognised in English, German, French, Spanish, Italian, Dutch and Portuguese. A page counts as an invoice or receipt only when it says so ("Invoice", "Receipt", "Rechnung", "Facture", ...). The vendor is a guess (the most prominent name at the top), so its confidence is halved. Dates such as 03/04/2025 are read month first on dollar invoices and day first otherwise.

Your own words

A word list helps with names, places and the vocabulary of your field, which the built-in dictionary may lack. Put one word per line in a text file (lines starting with # are comments) and pass --words FILE (more than one file is allowed). glyphwise-server and glyphwise-gui take --words too; the desktop window also reads words.txt in its settings folder (%APPDATA%\Glyphwise on Windows). From your own programs: glyphwise_add_words in C, add_words / AddWords / addWords in the wrappers. Words the recognizer reads clearly are not changed; the list decides between likely readings.

Tables

Glyphwise finds tables on scanned pages and puts the recognized words into their cells. It recognizes two kinds: tables drawn with lines between the cells (forms, government tables), and typeset tables with horizontal lines above and below and columns of figures between them. Cells that span several columns or rows are kept as merged cells. --xlsx FILE writes an Excel workbook with one sheet per table; plain numbers become numbers, everything else stays text exactly as read. --csv FILE writes every table one after another. The JSON output lists each page's tables with rows, columns and cell boxes. The HTTP service takes ?format=xlsx or ?format=csv. The library gives the same tables to programs: format 4 of the C API is the CSV, and the Python, .NET, Java, Node.js and Go wrappers return each table as typed cells (doc.tables(), table.grid(); see bindings/README.md).

Tables without any lines (columns set apart only by spacing) are found too when they are dense and regular: at least three rows and three columns of short entries. Prose in two or three columns is not taken for a table. PDFs that already have a text layer are read from that layer, without table detection; use --force-ocr to find their tables.

Languages

Glyphwise reads English and other languages written in the Latin alphabet, and Chinese (see below). Language models ship for English (en), French (fr), German (de), Spanish (es), Italian (it), Portuguese (pt), Dutch (nl), Polish (pl), Czech (cs), Slovak (sk), Hungarian (hu), Swedish (sv), Danish (da), Finnish (fi), Estonian (et), Latvian (lv), Lithuanian (lt), Slovenian (sl), Croatian (hr), Romanian (ro), Maltese (mt), Irish (ga), Turkish (tr), Norwegian Bokmål (nb), Icelandic (is), Catalan (ca), Galician (gl), Welsh (cy) and Chinese (zh). A language model corrects likely misreadings using the spelling of the language; English is the default. --lang CODE picks another (--lang list prints the codes your model has); the files are models/line.bin.<code>.lm next to the model. The HTTP service takes ?lang=fr per request (its /health lists the languages, --lang sets the default), and the C library has glyphwise_recognize_lang.

--lang auto (also ?lang=auto, and Automatic in the desktop window) picks the language per page: the page is read once, and the language model that fits that reading best is used to finish it. The JSON output says which ("language" per page).

Chinese (Simplified), --lang zh (also ?lang=zh and the desktop language menu), is read by the accurate model (models/line-accurate.bin), which has the 6,763 characters of GB 2312; the fast model does not. With --lang auto, a page the fast model reads with low confidence is read again by the accurate model and kept when it turns out to be Chinese. Horizontal text only; vertical text and Traditional characters are not read yet. Chinese pages take about three times as long as with the fast model.

--lang none (also ?lang=none) reads without any language model. Use it for a language that has no model of its own: another language's model "corrects" words it does not know (Finnish read with the English model has about four times as many errors as without one).

Hot folder

glyphwise models\line.bin --watch C:\Scans\in --out-dir C:\Scans\out --formats pdf,txt keeps running and reads every supported file that appears in the folder, once it has finished copying. The results are written to --out-dir (each output appears complete, never half-written), and the input moves to in\done, or to in\failed together with a note saying why. A name already used in the output folder gets -2, -3, ... --done DIR and --failed DIR choose other folders, --interval SECS the polling interval (default 5), and --once reads what is there now and stops, for scheduled tasks. Stop it with Ctrl+C. Without a licence the hot folder handles one batch (three pages) and stops.

Redacting personal data

--redact KINDS blacks out personal data before anything is written: email, ssn (US social security numbers), phone, card (payment card numbers, checked with the Luhn digit), iban (checked with its checksum), or all. --redact-terms FILE adds your own words or phrases, one per line (names, account numbers). Matched words become █ in the text, JSON, tables and form fields; in a searchable PDF they are painted black on the page image and left out of the hidden text, so they cannot be copied or searched. A summary of what was redacted goes to the console. The HTTP service takes ?redact=all (or a list of kinds). Only what was read can be redacted: check the result before you share it.

Fast or accurate

Packages can hold two main models: models/line.bin (fast, the default) and models/line-accurate.bin, a larger model that makes about 15% fewer word errors on printed text and takes about twice as long per page. It shares the language files of line.bin; handwriting is read the same way in both modes.

glyphwise models\line.bin report.pdf --accurate
curl --data-binary @scan.pdf "http://127.0.0.1:8080/ocr?mode=accurate"

glyphwise --accurate reads with the accurate model next to the one named. glyphwise-server loads it when it is present and reads with it on requests with ?mode=accurate (/health lists the modes; --accurate makes it the default, --no-accurate skips loading it). In the desktop window, choose Model: Accurate. From your own programs, open models/line-accurate.bin instead of models/line.bin.

Handwriting

models/handwriting.bin is a second reader for handwritten and mixed documents. With --alt models\handwriting.bin (on glyphwise and glyphwise-server), every line the main model is unsure of is read again by the handwriting model, and the more confident reading is kept:

glyphwise models\line.bin letter.jpg --alt models\handwriting.bin
glyphwise-server --model models\line.bin --alt models\handwriting.bin

On handwritten lines it makes about one character error in ten fewer (Bentham manuscripts: 12.9% -> 11.9% character errors). On printed pages it changes nothing measurable, but only lines the main model is unsure of are read twice, so it costs extra time mainly on handwriting. Handwriting is still much harder than print: expect to proof-read handwritten text.

Using Glyphwise from your own programs

The bindings/ folder holds ready wrappers for Python, .NET (C#), Java, Node.js and Go, and examples/ has short programs for C, C# and Python using the C API directly. Each wrapper reads a file, returns the document as typed objects (pages, lines, words with text, confidence and box), raises errors as exceptions, takes a language code, and can be shared by several threads. bindings/README.md shows each one in a few lines; point it at the library in this folder with the GLYPHWISE_LIB environment variable, or copy the library next to your program. Building Glyphwise into your own application is covered by the Developer licence.

Desktop window

Install it with glyphwiseocr-<version>-windows-x64-setup.exe: it installs for your user only (no administrator rights needed; choose "for all users" in the first dialog to install into Program Files), adds Glyphwise and Glyphwise command prompt to the Start menu and can add a desktop icon, Open with Glyphwise on PDFs and images in Explorer, and the command-line programs to PATH. If you have a licence file, choose it during setup. Uninstall from Windows Settings > Apps. The zip package works without installing: double-click glyphwise-gui.exe.

Glyphwise opens in its own window (Microsoft Edge or Google Chrome in app mode; without either, a tab of your default browser). Drop files or whole folders on it, or use Add files / Add folder, tick the output formats (plain text, JSON, hOCR, ALTO, searchable PDF with its DPI, review list of words below a confidence, tables as Excel or CSV), choose the language, then Convert all. Each document gets download links; Download all (.zip) collects every result, and Save into folder also writes the files into a folder (type it or click Browse…; existing files of the same name are replaced; Folder next to a saved document shows it in Explorer). Click a converted document to see its pages with the recognized words outlined and low-confidence words highlighted, or its text. Cancel stops the conversion (a document being read stops before its next page). Your choices of formats, language and folder are remembered.

Starting Glyphwise again, or Open with Glyphwise on more files, adds them to the window that is already open. Closing the window stops the program (the window asks first while documents are still being converted). If the connection to the program is lost, the window says so and retries.

From a console:

glyphwise-gui [--model models\line.bin] [FILE...]

Options: --port N (default: a free port), --no-browser (only print the address; runs until Ctrl+C or Quit), --browser (default browser instead of an app window), --new-instance (a separate window and program), --workers N (documents converted at once), --max-upload-mb N (default 512 MB per file), --gpu, --alt MODEL, --lang CODE and --license FILE, as for glyphwise. The handwriting model models\handwriting.bin is used automatically when it is in the package, and so is models\line-accurate.bin (the Model choice on the page); Advanced on the page turns on the GPU or loads another one. Problems are written to %LOCALAPPDATA%\Glyphwise\glyphwise-gui.log.

The page is served on 127.0.0.1 only and every request needs the random key in the address the program prints, so other computers and other web pages cannot use it. Documents never leave this computer; results are kept in a temporary folder that is removed when the program stops. Without a licence each Convert all works like one evaluation run of glyphwise: the first 3 files and at most 3 pages. Install licence… on the page (or the Evaluation badge) installs your licence file for your user and lifts the limits at once.

HTTP service

glyphwise-server --model models\line.bin --addr 127.0.0.1:8080
curl --data-binary @scan.pdf "http://127.0.0.1:8080/ocr"              (JSON)
curl --data-binary @scan.pdf "http://127.0.0.1:8080/ocr?format=text"  (plain text)
curl --data-binary @scan.pdf "http://127.0.0.1:8080/ocr?format=alto"  (ALTO XML; also format=hocr)

By default the service listens on this computer only (127.0.0.1). To serve other machines:

  • Require a token. Put a long random string in a file and start with --token-file token.txt (or set the GLYPHWISE_TOKEN environment variable). Clients then send Authorization: Bearer <token>; /health stays open for monitoring. The server warns at start-up when it listens beyond this computer without a token.
  • Or give each client its own key. List keys in a file, one NAME KEY per line (keys of at least 16 characters, # for comments), and start with --api-keys keys.txt. Clients send Authorization: Bearer KEY or X-API-Key: KEY; each request logs the key's name (never the key). The file is re-read when it changes, so deleting a line revokes that key at once, without a restart.
  • Add encryption. The service speaks plain HTTP; put a reverse proxy with TLS (IIS, nginx, Caddy) in front.

?redact=all (or email,ssn,phone,card,iban) blacks out personal data in the response, as --redact does.

Limits protect the service from oversized or slow requests: --max-body-mb (default 64 MB per upload), --max-pages (default 500 pages per request; longer documents are refused with status 413 before any work is done), --timeout-secs (default 120 s to receive a request) and --workers (requests processed at once; more wait their turn).

C API

glyphwise_open(model_path) returns a handle, glyphwise_recognize(handle, bytes, len, format) returns a string (format 0 = JSON, 1 = text, 2 = hOCR, 3 = ALTO) to release with glyphwise_free_string, and glyphwise_close releases the handle. On failure functions return NULL and glyphwise_last_error() says why.

If your application keeps the licence somewhere other than the places listed under "Licence file", call glyphwise_set_license_file(path) or glyphwise_set_license_text(contents) before glyphwise_open; both return 1 when the licence is accepted. glyphwise_license_status() returns 1 when licensed and 0 in evaluation mode, and glyphwise_license_info() returns the details as text.

GPU

--gpu uses CUDA when an NVIDIA driver and the CUDA runtime compiler (NVRTC) are installed, otherwise OpenCL, otherwise it falls back to the CPU and says so. Results are the same either way; the GPU is faster on large batches.

Accuracy notes

  • Best on printed documents scanned at 200–300 dpi. Very small text (< 8 px x-height) and heavy noise reduce accuracy.
  • Phone photos of pages work: pages turned sideways or upside down are set upright (also from the photo's orientation tag), a page photographed at an angle on a darker surface is straightened, and shadows and uneven light are evened out. For best results photograph the whole page, flat, in even light, against a darker background. Word boxes always refer to the original photo. --no-prepare turns these repairs off.
  • Handwriting is supported but much harder; expect noticeably more errors than on print.
  • JSON gives a confidence per word (0–1); low values mark words worth checking. --review FILE lists the words below 0.8 (--review-threshold) with page, line, box and the line's text, ready for a spreadsheet.