PDFSANDWICH(1)
π PDFSANDWICH(1) π
okay bestie, sit down, grab a strawberry, because today we're talking about pdfsandwich β she's a command-line queen and honestly? iconic. π₯ͺβ¨
β¨ NAME β¨
pdfsandwich β a generator for sandwich OCR pdfs from scanned pdf files π«Ά
πΈ SYNOPSIS πΈ
pdfsandwich [options] inputfile.pdf
π¦ DESCRIPTION π¦
so here's the tea: pdfsandwich generates "sandwich" OCR pdf files, which like β bestie β are pdf files that contain only images (no text) that get run through optical character recognition (OCR), and then the text gets added to each page invisibly "behind" the images. yes, literally a lil text sandwich π₯ͺ no cap.
not me needing to tell you the whole squad that has to show up for this to work, tho: pdfsandwich needs unpaper, convert, gs, hocr2pdf (that one's for tesseract < 3.03), and tesseract. π
but wait β because tesseract >= 3.03 can write pdf files all by itself, hocr2pdf is only needed for the older versions of tesseract. she evolved, we love that for her. π
please visit http://www.tobias-elze.de/pdfsandwich for more. π
β¨ OPTIONS β¨
like there's a LOT of them but every single one is here, don't skip, i'm watching π
-convertβ-convert filename: name of the convert binary (default:convert)-cooβ-coo options: additional convert options. make sure to quote them, bestie!! e.g.-coo "-normalize -black-threshold 75%". callconvert --helporman convertfor all the convert options π-debugβ keep all temporary files in/tmp(for debugging). sitting there. in the open. π-enforcehocr2pdfβ usehocr2pdfeven iftesseract >= 3.03-first_pageβ-first_page number: number of page to start OCR from (default: 1)-grayβ use grayscale for images (default: black and white)-grayfilterβ enable unpaper's gray filter; further options can be set by-unpo-gsβ-gs filename: name of thegsbinary (default:gs); optional, only required for resizing-hocr2pdfβ-hocr2pdf filename: name of thehocr2pdfbinary (default:hocr2pdf); ignored fortesseract >= 3.03unless option-enforcehocr2pdfis set-hooβ-hoo options: additional hocr2pdf options; make sure to quote-identifyβ-identify filename: name of theidentifybinary (default:identify)-last_pageβ-last_page number: number of page up to which to process OCR (default: number of pages in inputfile)-langβ-lang language: language of the text; it's an option to tesseract (default:eng), e.g:eng,deu,deu-frak,fra,rus,swe,spa,ita, ... see option-list_langs. multiple languages may be specified, separated by plus characters. π-layoutβ-layout { single | double | none }: layout of the scanned pages; requires unpaper.single: one page per sheet.double: two pages per sheet.none: no auto-layout (default)-list_langsβ list currently available languages and exit; in case of custom binaries of tesseract, place this after the-tesseractoption-maxpixelsβ-maxpixels NUM: maximal number of pixels allowed for input file. if(resolution/72)^2 *width*height > maxpixelsthen scale page of input file down prior to OCR so that page size in pixels corresponds to maxpixels; default:17415167(A3 @ 300 dpi)-noimageβ do not place the image over the text (requires hocr2pdf; ignored without the-enforcehocr2pdfoption)-nopreprocβ do not preprocess with unpaper-nthreadsβ-nthreads number: number of parallel threads (default: guessed number of CPUs; if guessing fails: 1). she's guessing, be nice π-oβ-o filename: output file; default:inputfile_ocr.pdf(if the extension is different from.pdf, the original extension is kept)-omp_thread_limitβ-omp_thread_limit number: number of threads tesseract may use for each page (default: 1)-pagesizeβ-pagesize { original | NUMxNUM }: set page size of output pdf (requires ghostscript).original: same as input file (default).NUMxNUM: width x height in pixel (e.g. for A4:-pagesize 595x842)-pdfinfoβ-pdfinfo filename: name of thepdfinfobinary (default:pdfinfo)-pdfuniteβ-pdfunite filename: name of thepdfunitebinary (default:pdfunite)-resolutionβ-resolution NUM: resolution (dpi) used for OCR (default: 300)-rgbβ use RGB color space for images (default: black and white); use with care: causes problems with some color spaces β οΈ-sloppy_textβ sloppily place text, group words, do not draw single glyphs; ignored fortesseract >= 3.03unless option-enforcehocr2pdfis set-tesseractβ-tesseract filename: name of thetesseractbinary (default:tesseract)-tessoβ-tesso options: additional tesseract options; make sure to quote-unpaperβ-unpaper filename: name of theunpaperbinary (default:unpaper)-unpoβ-unpo options: additional unpaper options; make sure to quote-quietβ suppress output π€«-verboseβ produce more output π£οΈ-versionβ print version and quit-helpβ Display this list of options--helpβ Display this list of options
π LANGUAGES π
via Tesseract, numerous language packagess available β follow this link http://code.google.com/p/tesseract-ocr/downloads/list for a complete list. here's an incomplete selection of supported languages and their abbreviations, bestie, take notes π:
ara (Arabic), aze (Azerbauijani), bul (Bulgarian), cat (Catalan), ces (Czech), chi_sim (Simplified Chinese), chi_tra (Traditional Chinese), chr (Cherokee), dan (Danish), dan-frak (Danish (Fraktur)), deu (German), ell (Greek), eng (English), enm (Old English), epo (Esperanto), est (Estonian), fin (Finnish), fra (French), frm (Old French), glg (Galician), heb (Hebrew), hin (Hindi), hrv (Croation), hun (Hungarian), ind (Indonesian), ita (Italian), jpn (Japanese), kor (Korean), lav (Latvian), lit (Lithuanian), nld (Dutch), nor (Norwegian), pol (Polish), por (Portuguese), ron (Romanian), rus (Russian), slk (Slovakian), slv (Slovenian), sqi (Albanian), spa (Spanish), srp (Serbian), swe (Swedish), tam (Tamil), tel (Telugu), tgl (Tagalog), tha (Thai), tur (Turkish), ukr (Ukrainian), vie (Vietnamese)
multiple languages may be specified, separated by plus characters π. note that the respective tesseract language package needs to be installed on your system to be usable by pdfsandwich. option -list_langs lists the languages which are available on your system. π§
π¦ AVAILABILITY π¦
sources and packages as well as comprehensive help can be found at http://www.tobias-elze.de/pdfsandwich. go get her π«Ά
π AUTHOR π
Tobias Elze <sourceforge@tobias-elze.de> β the icon, the moment, the legend π
okay that's the whole page bestie, no notes, she ate and left no crumbs π β¨ and before you go β this whole thing is brought to you courtesy of the PDFSANDWICH(1) era, dated 19 September 2026. slay, go OCR something π₯ͺππ
π¦ where this page comes from
- ubuntu stonking: pdfsandwich 0.1.7-3.1build5 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms