/usr/share/doc/ocrmypdf/html/advanced.html is in ocrmypdf-doc 6.1.2-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | <!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced features — ocrmypdf 6.1.2 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="ocrmypdf 6.1.2 documentation" href="index.html"/>
<link rel="next" title="Batch processing" href="batch.html"/>
<link rel="prev" title="Cookbook" href="cookbook.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> ocrmypdf
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="release_notes.html">Release notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="languages.html">Installing additional language packs</a></li>
</ul>
<p class="caption"><span class="caption-text">Usage</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="cookbook.html">Cookbook</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Advanced features</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#control-of-ocr-options">Control of OCR options</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#when-ocr-is-skipped">When OCR is skipped</a></li>
<li class="toctree-l3"><a class="reference internal" href="#time-and-image-size-limits">Time and image size limits</a></li>
<li class="toctree-l3"><a class="reference internal" href="#overriding-default-tesseract">Overriding default tesseract</a></li>
<li class="toctree-l3"><a class="reference internal" href="#overriding-other-support-programs">Overriding other support programs</a></li>
<li class="toctree-l3"><a class="reference internal" href="#changing-tesseract-configuration-variables">Changing tesseract configuration variables</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#changing-the-pdf-renderer">Changing the PDF renderer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#the-sandwich-renderer">The <code class="docutils literal"><span class="pre">sandwich</span></code> renderer</a></li>
<li class="toctree-l3"><a class="reference internal" href="#the-hocr-renderer">The <code class="docutils literal"><span class="pre">hocr</span></code> renderer</a></li>
<li class="toctree-l3"><a class="reference internal" href="#the-tesseract-renderer">The <code class="docutils literal"><span class="pre">tesseract</span></code> renderer</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="batch.html">Batch processing</a></li>
<li class="toctree-l1"><a class="reference internal" href="security.html">PDF security issues</a></li>
<li class="toctree-l1"><a class="reference internal" href="errors.html">Common error messages</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">ocrmypdf</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>Advanced features</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/advanced.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="advanced-features">
<h1>Advanced features<a class="headerlink" href="#advanced-features" title="Permalink to this headline">¶</a></h1>
<div class="section" id="control-of-ocr-options">
<h2>Control of OCR options<a class="headerlink" href="#control-of-ocr-options" title="Permalink to this headline">¶</a></h2>
<p>OCRmyPDF provides many features to control the behavior of the OCR engine, Tesseract.</p>
<div class="section" id="when-ocr-is-skipped">
<h3>When OCR is skipped<a class="headerlink" href="#when-ocr-is-skipped" title="Permalink to this headline">¶</a></h3>
<p>If a page in a PDF seems to have text, by default OCRmyPDF will exit without modifying the PDF. This is to ensure that PDFs that were previously OCRed or were “born digital” rather than scanned are not processed.</p>
<p>If <code class="docutils literal"><span class="pre">--skip-text</span></code> is issued, then no OCR will be performed on pages that already have text. The page will be copied to the output. This may be useful for documents that contain both “born digital” and scanned content, or to use OCRmyPDF to normalize and convert to PDF/A regardless of their contents.</p>
<p>If <code class="docutils literal"><span class="pre">--force-ocr</span></code> is issued, then all pages will be rasterized to images, discarding any hidden OCR text, and rasterizing any printable text. This is useful for redoing OCR, for fixing OCR text with a damaged character map (text is selectable but not searchable), and destroying redacted information.</p>
</div>
<div class="section" id="time-and-image-size-limits">
<h3>Time and image size limits<a class="headerlink" href="#time-and-image-size-limits" title="Permalink to this headline">¶</a></h3>
<p>By default, OCRmyPDF permits tesseract to run for only three minutes (180 seconds) per page. This is usually more than enough time to find all text on a reasonably sized page with modern hardware.</p>
<p>If a page is skipped, it will be inserted without OCR. If preprocessing was requested, the preprocessed image layer will be inserted.</p>
<p>If you want to adjust the amount of time spent on OCR, change <code class="docutils literal"><span class="pre">--tesseract-timeout</span></code>. You can also automatically skip images that exceed a certain number of megapixels with <code class="docutils literal"><span class="pre">--skip-big</span></code>. (A 300 DPI, 8.5×11” page is 8.4 megapixels.)</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># Allow 300 seconds for OCR; skip any page larger than 50 megapixels</span>
ocrmypdf --tesseract-timeout <span class="m">300</span> --skip-big <span class="m">50</span> bigfile.pdf output.pdf
</pre></div>
</div>
</div>
<div class="section" id="overriding-default-tesseract">
<h3>Overriding default tesseract<a class="headerlink" href="#overriding-default-tesseract" title="Permalink to this headline">¶</a></h3>
<p>OCRmyPDF checks the system <code class="docutils literal"><span class="pre">PATH</span></code> for the <code class="docutils literal"><span class="pre">tesseract</span></code> binary.</p>
<dl class="envvar">
<dt id="envvar-TESSDATA_PREFIX">
<code class="descname">TESSDATA_PREFIX</code><a class="headerlink" href="#envvar-TESSDATA_PREFIX" title="Permalink to this definition">¶</a></dt>
<dd><p>A Tesseract environment variable that overrides the path to Tesseract’s data files.</p>
</dd></dl>
<p>For example, if you are testing tesseract 4.00 and don’t wish to use an existing tesseract 3.04 installation, you can launch OCRmyPDF as follows:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>env <span class="se">\</span>
<span class="nv">PATH</span><span class="o">=</span>/home/user/src/tesseract4/api:<span class="nv">$PATH</span> <span class="se">\</span>
<span class="nv">TESSDATA_PREFIX</span><span class="o">=</span>/home/user/src/tesseract4 <span class="se">\</span>
ocrmypdf --tesseract-oem <span class="m">2</span> input.pdf output.pdf
</pre></div>
</div>
<p>In this example <code class="docutils literal"><span class="pre">TESSDATA_PREFIX</span></code> directs Tesseract 4.0 to use LSTM training data. <code class="docutils literal"><span class="pre">--tesseract-oem</span> <span class="pre">1</span></code> requests tesseract 4.0’s new LSTM engine. (Tesseract 4.0 only.)</p>
</div>
<div class="section" id="overriding-other-support-programs">
<h3>Overriding other support programs<a class="headerlink" href="#overriding-other-support-programs" title="Permalink to this headline">¶</a></h3>
<p>In addition to tesseract, OCRmyPDF uses the following external binaries:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">gs</span></code> (Ghostscript)</li>
<li><code class="docutils literal"><span class="pre">unpaper</span></code></li>
<li><code class="docutils literal"><span class="pre">qpdf</span></code></li>
</ul>
<p>In each case OCRmyPDF will search the <code class="docutils literal"><span class="pre">PATH</span></code> environment variable to locate the binaries.</p>
</div>
<div class="section" id="changing-tesseract-configuration-variables">
<h3>Changing tesseract configuration variables<a class="headerlink" href="#changing-tesseract-configuration-variables" title="Permalink to this headline">¶</a></h3>
<p>You can override tesseract’s default <a class="reference external" href="https://github.com/tesseract-ocr/tesseract/wiki/ControlParams">control parameters</a> with a configuration file.</p>
<p>As an example, this configuration will disable Tesseract’s dictionary for current language. Normally the dictionary is helpful for interpolating words that are unclear, but it may interfere with OCR if the document does not contain many words (for example, a list of part numbers).</p>
<p>Create a file named “no-dict.cfg” with these contents:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">load_system_dawg</span> <span class="mi">0</span>
<span class="n">language_model_penalty_non_dict_word</span> <span class="mi">0</span>
<span class="n">language_model_penalty_non_freq_dict_word</span> <span class="mi">0</span>
</pre></div>
</div>
<p>then run ocrmypdf as follows (along with any other desired arguments):</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>ocrmypdf --tesseract-config no-dict.cfg input.pdf output.pdf
</pre></div>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Some combinations of control parameters will break Tesseract or break assumptions that OCRmyPDF makes about Tesseract’s output.</p>
</div>
</div>
</div>
<div class="section" id="changing-the-pdf-renderer">
<h2>Changing the PDF renderer<a class="headerlink" href="#changing-the-pdf-renderer" title="Permalink to this headline">¶</a></h2>
<dl class="docutils">
<dt>rasterizing</dt>
<dd>Converting a PDF to an image for display.</dd>
<dt>rendering</dt>
<dd>Creating a new PDF from other data (such as an existing PDF).</dd>
</dl>
<p>OCRmyPDF has three PDF renderers: <code class="docutils literal"><span class="pre">sandwich</span></code>, <code class="docutils literal"><span class="pre">hocr</span></code>, <code class="docutils literal"><span class="pre">tesseract</span></code>. The renderer may be selected using <code class="docutils literal"><span class="pre">--pdf-renderer</span></code>. The default is <code class="docutils literal"><span class="pre">auto</span></code> which lets OCRmyPDF select the renderer to use. Currently, <code class="docutils literal"><span class="pre">auto</span></code> selects <code class="docutils literal"><span class="pre">sandwich</span></code> for Tesseract 3.05.01 or newer, or <code class="docutils literal"><span class="pre">hocr</span></code> for older versions of Tesseract.</p>
<div class="section" id="the-sandwich-renderer">
<h3>The <code class="docutils literal"><span class="pre">sandwich</span></code> renderer<a class="headerlink" href="#the-sandwich-renderer" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal"><span class="pre">sandwich</span></code> renderer uses Tesseract’s new text-only PDF feature, which produces a PDF page that lays out the OCR in invisible text. This page is then “sandwiched” onto the original PDF page, allowing lossless application of OCR even to PDF pages that contain other vector objects.</p>
<p>When image preprocessing features like <code class="docutils literal"><span class="pre">--deskew</span></code> are used, the original PDF will be rendered as a full page and the OCR layer will be placed on top.</p>
<p>This renderer requires Tesseract 3.05.01 or newer.</p>
</div>
<div class="section" id="the-hocr-renderer">
<h3>The <code class="docutils literal"><span class="pre">hocr</span></code> renderer<a class="headerlink" href="#the-hocr-renderer" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal"><span class="pre">hocr</span></code> renderer works with older versions of Tesseract. The image layer is copied from the original PDF page if possible, avoiding potentially lossy transcoding or loss of other PDF information. If preprocessing is specified, then the image layer is a new PDF.</p>
<p>This works in all versions of Tesseract.</p>
</div>
<div class="section" id="the-tesseract-renderer">
<h3>The <code class="docutils literal"><span class="pre">tesseract</span></code> renderer<a class="headerlink" href="#the-tesseract-renderer" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal"><span class="pre">tesseract</span></code> renderer creates a PDF with the image and text layers precomposed, meaning that it always transcodes, loses image quality and rasterizes any vector objects. It does a better job on non-Latin text and document structure than <code class="docutils literal"><span class="pre">hocr</span></code>.</p>
<p>If a PDF created with this renderer using Tesseract versions older than 3.05.00 is then passed through Ghostscript’s pdfwrite feature, the OCR text <em>may</em> be corrupted. The <code class="docutils literal"><span class="pre">--output-type=pdfa</span></code> argument will produce a warning in this situation.</p>
<p><em>This renderer is deprecated and will be removed whenever support for older versions of Tesseract is dropped.</em></p>
</div>
</div>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="batch.html" class="btn btn-neutral float-right" title="Batch processing" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="cookbook.html" class="btn btn-neutral" title="Cookbook" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2018, James R. Barlow. Licensed under Creative Commons Attribution-ShareAlike 4.0..
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'6.1.2',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
|