Usage¶
Common tasks. Every option is listed in the manual (kurdpdf manual) and in kurdpdf convert -h.
Look before converting¶
The font table shows each font's class (see fonts-and-atlas.md). The page
table shows the method each page will use, the share of glyphs identified (coverage) and the
shape-back verification score. inspect never runs OCR and writes nothing.
Convert¶
kurdpdf book.pdf # book.txt next to the PDF
kurdpdf book.pdf --format md,docx --out out/ # Markdown and Word
kurdpdf book.pdf --format all --pages 1-20 # every format for pages 1 to 20
kurdpdf book.pdf --format odt,rtf,tex --font Vazirmatn # LibreOffice, Word (RTF), LaTeX
kurdpdf book.pdf --layer resolved # without the orthography rules
kurdpdf book.pdf --no-furniture # without page numbers and running headers
kurdpdf book.pdf --rules +swap-brackets # turn ( ) round in right-to-left lines: )یوسف( -> (یوسف)
kurdpdf book.pdf --language fa # every Arabic-script line is Persian (auto, ckb, fa, ar, off)
kurdpdf book.pdf --no-tables # ruled tables as plain lines, not cells
Each line's language is detected (--language auto, the default): Kurdish lines are normalized,
Persian and Arabic lines keep their letters (Persian takes ی ک), English lines are left alone, and
the exports tag each paragraph with its language so spell checkers and screen readers pick the right
one. Lines shorter than three words take the language of their own script on the page. Force one
language for every Arabic-script line with ckb, fa or ar when detection gets a book wrong;
off records no languages and tags all right-to-left text as Kurdish. In the config file:
[orthography] language = "auto".
Existing files are not replaced unless you pass --overwrite (exit code 5 otherwise).
Cut, merge and turn pages¶
kurdpdf pages works on pages without changing the input file. extract and split can convert
what they write in the same step.
kurdpdf pages info book.pdf # sizes, turns, text layer or scan
kurdpdf pages extract book.pdf --pages 5-20 # book-pages-5-20.pdf
kurdpdf pages extract book.pdf --pages 5-20 --format txt,docx --text-out text/
kurdpdf pages split book.pdf --every 10 --out parts/ # book-1-10.pdf, book-11-20.pdf, ...
kurdpdf pages split book.pdf --at 30,90 --format all # three parts, each converted to every format
kurdpdf pages merge cover.pdf book.pdf:3-200 -o clean.pdf
kurdpdf pages rotate scan.pdf --pages 2,4 --angle 90
kurdpdf pages delete book.pdf --pages 1,2
kurdpdf pages images book.pdf --pages 1-3 --dpi 200 --image-format jpg
To convert only some pages without writing a PDF, use kurdpdf convert book.pdf --pages 5-20.
Many files¶
kurdpdf convert library/ --recursive --format txt,json --out out/
kurdpdf convert "scans/**/*.pdf" --out out/ # a quoted glob, expanded by KurdPDF
A file that fails does not stop the others. The summary lists done, warned and failed files, and
the exit code is 1 when any failed. Use --max-pages and --max-file-mb to skip huge inputs.
In the browser¶
kurdpdf web # opens a local page; Ctrl-C stops it
kurdpdf web --port 0 --no-browser
kurdpdf web --keep-token # same address every run, for a bookmark or the installed app
The page is a PDF page editor. Open or drop one or more PDFs; the navigator on the left shows
the pages in a grid or a list. Select one page, several (Ctrl or Shift click, long press on a
phone) or all, then rotate, duplicate, delete, extract, move or reorder them by dragging. Add
pages from other PDFs or blank pages at the start, the end or after any page. Every change can
be undone. Open starts a new document from the chosen files; Close (or a click on the logo)
closes every file and goes back to the start page, asking first when there are unsaved changes. Export the whole document, the selection or a range as a PDF, one PDF per page, or
PNG or JPG images at the DPI you choose. To text converts the same pages (its dialog also opens as soon as a file is opened, so you can
convert right away or cancel and edit the pages first): look at the Pages,
Fonts and Warnings tabs before downloading TXT, Markdown, DOCX, ODT, RTF, HTML, LaTeX, EPUB or JSON. The page can be
installed as an app and works on phones. Nothing leaves your computer. See kurdpdf manual for the options and the [web]
config section.
In the Text tab, turn on Pages to see each page image beside its text, and Sync to scroll
both together; click a paragraph to mark it on the page, or a place on the page to jump to its
text. Hover over the pages for the zoom controls: zoom out and in (or Ctrl + wheel, and + -
with the pages focused), the zoom level (click it for 100%), Fit width (0) and Whole page;
the zoom is remembered. Each page also shows buttons to show the whole page, copy that page's text
and save the page as an image. Fonts and text size… (menu, or the Aa button) picks the right-to-left font (Sahel,
Vazirmatn, Estedad, any installed Arabic font, or a font file you load) and the left-to-right font
(Manrope); the choice and loaded files stay in your browser until you remove them or clear its
site data. Save as… lists every format; for Word's old .doc, save RTF and open it in Word.
The Layer menu picks what is shown and saved: zimankit: all fixes (the orthography layer), no fixes (the text as read from the glyphs), raw (the PDF's own text layer), or zimankit: check fixes one by one. That last one starts from the text with no fixes and underlines every word zimankit would change. Step through them with the arrows (or N and P), then press Apply (A) or Keep original (K), which moves to the next fix. You can also click a word to switch it. Fix all applies every fix, Reset all takes them all out, and Undo/Redo (Ctrl+Z, Ctrl+Shift+Z) step back through every change, a Fix all or Reset all included. Copy text, TXT and Save as… write exactly what is shown. Fixes inside table cells are counted and saved, but are not underlined.
Reviewing glyphs KurdPDF cannot read¶
kurdpdf review scan books/ --recursive # record unread and guessed glyphs in temp/review/
kurdpdf review serve # give each outline its character in the browser
kurdpdf book.pdf --review-labels temp/review/labels.json
kurdpdf review check # does the engine alone agree with each decision?
One decision covers every occurrence of an outline in every scanned file. The dashboard works on a
phone too: tap a glyph, swipe for the next one, and go back with ☰ List. See kurdpdf manual.
Settings picks the theme (system, light or dark) and the font of the Kurdish text: Sahel by
default, Estedad or Vazirmatn when they are installed on the laptop, or a font you add by its path on
the laptop or by dropping the file on the page. Added fonts are copied into temp/review/fonts/;
the choices are kept in each browser.
Start and stop it as a service (Linux, systemd)¶
scripts/kurdpdf-review runs the dashboard as a systemd user service that is on only while you use
it. systemd holds the port, the dashboard starts when you open the link (in about a second) and
exits after 30 minutes without requests (--idle 0 never exits). Nothing starts at login unless you
ask.
scripts/kurdpdf-review install # this computer only (127.0.0.1:8766)
scripts/kurdpdf-review install --host 10.8.0.2 --name laptop.vpn # reachable over your VPN
kurdpdf-review start # listen; open the printed link (bookmark it, it keeps its token)
kurdpdf-review stop # stop listening and stop the dashboard
kurdpdf-review status # listening? running now? starts at login?
kurdpdf-review url # the link again (and a QR code if qrencode is installed)
kurdpdf-review enable # listen from every login on (costs nothing until the link is opened)
kurdpdf-review disable # undo enable
kurdpdf-review logs # the dashboard's last log lines
kurdpdf-review new-token # new link; old links stop working
kurdpdf-review uninstall # remove the units (decisions and the token stay in temp/review/)
install links the script to ~/.local/bin/kurdpdf-review when that folder exists, writes
~/.config/systemd/user/kurdpdf-review.{socket,service} from contrib/systemd/, and keeps its
settings in ~/.config/kurdpdf/review.env. Run install again to change the address, port or idle
time. The service runs at low CPU and I/O priority with at most 1 GB of memory.
Reviewing from outside: connect your phone or other computer to the VPN, then open the link with the
laptop's VPN address. Use --host with the laptop's address on the VPN interface (ip -brief addr
lists them; install prints them too), not 0.0.0.0, which would also listen on café or hotel
Wi-Fi. --name adds a host name the VPN gives the laptop. If you want to start it from outside
too, run kurdpdf-review enable once: the socket then waits from every login on, and the dashboard
still runs only while you use it. (Units of a user run only while that user is logged in, unless
loginctl enable-linger is set.) The address works only with the token, and the server keeps the
kurdpdf web protections; the VPN encrypts the traffic.
Install it as an app (phone, tablet, desktop)¶
The dashboard is an installable web app (PWA): it gets its own icon and window, and when the laptop
is asleep or off the VPN it still opens with the last queue and glyphs you looked at, read-only
(saving needs the laptop; a banner says so). Browsers allow this only on 127.0.0.1/localhost or
over HTTPS, so for other devices install makes a local certificate authority and a certificate:
scripts/kurdpdf-review install --https --host 10.8.0.2 --name laptop.vpn
kurdpdf-review ca # where the CA file is and how to trust it on Android and iPhone
kurdpdf-review cert --host 10.8.0.2 # a new server certificate (new address); the CA stays
kurdpdf-review url # https:// link and QR code
The files are in ~/.config/kurdpdf/tls/. Trust ca.crt once on each device (Android: Settings >
Security > Encryption & credentials > Install a certificate > CA certificate; iPhone: open the
file, install the profile, then turn it on under General > About > Certificate Trust Settings).
Never copy ca.key anywhere. Then open the link and install: Chrome on Android offers "Install
app" (the dashboard also shows an Install button), Safari on iPhone uses Share > Add to Home Screen,
and desktop Chrome or Edge shows an install icon in the address bar. On the laptop itself,
http://127.0.0.1 works without HTTPS. A new token (new-token) means installing again.
Without systemd, run it by hand:
kurdpdf review serve --host 10.8.0.2 --keep-token --idle-minutes 30 --no-browser
kurdpdf review serve --host 10.8.0.2 --keep-token --tls-cert cert.pem --tls-key key.pem
Scanned books¶
kurdpdf scan.pdf # OCR runs by itself on scanned pages (needs Tesseract)
kurdpdf mixed.pdf --ocr always # OCR every page, even ones with a text layer
kurdpdf book.pdf --ocr never # never OCR
See ocr.md for setup and measured accuracy.
Check the result¶
- Warnings name the page and the cause:
low-coverage,low-verification,ambiguous,scanned,low-ocr-confidence, and so on. --strictmakes a run fail (exit code 6) when a page scores below--min-verification. The files are still written.- The JSON export (
--format json, add--glyphsfor every glyph) records for each page the method, coverage, the source of each resolved character, the verification score and OCR details.
From Python¶
from kurdpdf import KurdPDF
doc = KurdPDF("book.pdf", ocr="never").extract(pages=[1, 2, 3])
for page in doc.pages:
print(page.number, page.method, page.coverage, page.verification)
print(page.best_text())
from kurdpdf.converters import to_docx, to_json
open("book.docx", "wb").write(to_docx(doc))
KurdPDF(...) takes the same settings as the command line: atlas, lexicon, orthography,
min_verification, ocr, ocr_lang, tessdata, ocr_preprocess, max_pages, max_file_mb.
extract(progress=callback) calls callback(done, total) after each page.