This file is indexed.

/usr/share/doc/ocrmypdf/html/cookbook.html is in ocrmypdf-doc 4.3.5-3.

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
<!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>Cookbook &mdash; ocrmypdf 4.3.5 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 4.3.5 documentation" href="index.html"/>
        <link rel="next" title="PDF Security Issues" href="security.html"/>
        <link rel="prev" title="Installing additional language packs" href="languages.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 class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="languages.html">Installing additional language packs</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Cookbook</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#basic-examples">Basic examples</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#help">Help!</a></li>
<li class="toctree-l3"><a class="reference internal" href="#add-an-ocr-layer-and-convert-to-pdf-a">Add an OCR layer and convert to PDF/A</a></li>
<li class="toctree-l3"><a class="reference internal" href="#add-an-ocr-layer-and-output-a-standard-pdf">Add an OCR layer and output a standard PDF</a></li>
<li class="toctree-l3"><a class="reference internal" href="#modify-a-file-in-place">Modify a file in place</a></li>
<li class="toctree-l3"><a class="reference internal" href="#correct-page-rotation">Correct page rotation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#ocr-languages-other-than-english">OCR languages other than English</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#ocr-images-not-pdfs">OCR images, not PDFs</a></li>
<li class="toctree-l2"><a class="reference internal" href="#image-processing">Image processing</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#ocr-and-correct-document-skew-crooked-scan">OCR and correct document skew (crooked scan)</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#hot-watched-folders">Hot (watched) folders</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#caveats">Caveats</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#batch-jobs">Batch jobs</a></li>
</ul>
</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> &raquo;</li>
      
    <li>Cookbook</li>
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="_sources/cookbook.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="cookbook">
<h1>Cookbook<a class="headerlink" href="#cookbook" title="Permalink to this headline"></a></h1>
<div class="section" id="basic-examples">
<h2>Basic examples<a class="headerlink" href="#basic-examples" title="Permalink to this headline"></a></h2>
<div class="section" id="help">
<h3>Help!<a class="headerlink" href="#help" title="Permalink to this headline"></a></h3>
<p>ocrmypdf has built-in help.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>ocrmypdf --help
</pre></div>
</div>
</div>
<div class="section" id="add-an-ocr-layer-and-convert-to-pdf-a">
<h3>Add an OCR layer and convert to PDF/A<a class="headerlink" href="#add-an-ocr-layer-and-convert-to-pdf-a" title="Permalink to this headline"></a></h3>
<div class="highlight-bash"><div class="highlight"><pre><span></span>ocrmypdf input.pdf output.pdf
</pre></div>
</div>
</div>
<div class="section" id="add-an-ocr-layer-and-output-a-standard-pdf">
<h3>Add an OCR layer and output a standard PDF<a class="headerlink" href="#add-an-ocr-layer-and-output-a-standard-pdf" title="Permalink to this headline"></a></h3>
<div class="highlight-bash"><div class="highlight"><pre><span></span>ocrmypdf --output-type pdf input.pdf output.pdf
</pre></div>
</div>
</div>
<div class="section" id="modify-a-file-in-place">
<h3>Modify a file in place<a class="headerlink" href="#modify-a-file-in-place" title="Permalink to this headline"></a></h3>
<p>The file will only be overwritten if OCRmyPDF is successful.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>ocrmypdf myfile.pdf myfile.pdf
</pre></div>
</div>
</div>
<div class="section" id="correct-page-rotation">
<h3>Correct page rotation<a class="headerlink" href="#correct-page-rotation" title="Permalink to this headline"></a></h3>
<p>OCR will attempt to automatic correct the rotation of each page. This can help fix a scanning job that contains a mix of landscape and portrait pages.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>ocrmypdf --rotate-pages myfile.pdf myfile.pdf
</pre></div>
</div>
<p>You can increase (decrease) the parameter <code class="docutils literal"><span class="pre">--rotate-pages-threshold</span></code> to make page rotation more (less) aggressive.</p>
</div>
<div class="section" id="ocr-languages-other-than-english">
<h3>OCR languages other than English<a class="headerlink" href="#ocr-languages-other-than-english" title="Permalink to this headline"></a></h3>
<p>By default OCRmyPDF assumes the document is English.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>ocrmypdf -l fre LeParisien.pdf LeParisien.pdf
ocrmypdf -l eng+fre Bilingual-English-French.pdf Bilingual-English-French.pdf
</pre></div>
</div>
<p>Language packs must be installed for all languages specified. See <a class="reference internal" href="languages.html#lang-packs"><span class="std std-ref">Installing additional language packs</span></a>.</p>
</div>
</div>
<div class="section" id="ocr-images-not-pdfs">
<h2>OCR images, not PDFs<a class="headerlink" href="#ocr-images-not-pdfs" title="Permalink to this headline"></a></h2>
<p>Use a program like <a class="reference external" href="https://gitlab.mister-muffin.de/josch/img2pdf">img2pdf</a> to convert your images to PDFs, and then pipe the results to run ocrmypdf:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>img2pdf my-images*.jpg <span class="p">|</span> ocrmypdf - myfile.pdf
</pre></div>
</div>
<p>If given a single image as input, OCRmyPDF will try converting it to a PDF on its own.  This feature may be removed at some point, because OCRmyPDF does not specialize in converting images to PDFs.</p>
<p>You can also use Tesseract 3.04+ directly to convert single page images or multi-page TIFFs to PDF:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>tesseract my-image.jpg output-prefix pdf
</pre></div>
</div>
</div>
<div class="section" id="image-processing">
<h2>Image processing<a class="headerlink" href="#image-processing" title="Permalink to this headline"></a></h2>
<p>OCRmyPDF perform some image processing on each page of a PDF, if desired.  The same processing is applied to each page.  It is suggested that the user review files after image processing as these commands might remove desirable content, especially from poor quality scans.</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">--rotate-pages</span></code> attempts to determine the correct orientation for each page and rotates the page if necessary.</li>
<li><code class="docutils literal"><span class="pre">--remove-background</span></code> attempts to detect and remove a noisy background from grayscale or color images.  Monochrome images are ignored. This should not be used on documents that contain color photos as it may remove them.</li>
<li><code class="docutils literal"><span class="pre">--deskew</span></code> will correct pages were scanned at a skewed angle by rotating them back into place.  Skew determination and correction is performed using <a class="reference external" href="http://www.leptonica.com/skew-measurement.html">Postl&#8217;s variance of line sums</a> algorithm as implemented in <a class="reference external" href="http://www.leptonica.com/index.html">Leptonica</a>.</li>
<li><code class="docutils literal"><span class="pre">--clean</span></code> uses <a class="reference external" href="https://www.flameeyes.eu/projects/unpaper">unpaper</a> to clean up pages before OCR, but does not alter the final output.  This makes it less likely that OCR will try to find text in background noise.</li>
<li><code class="docutils literal"><span class="pre">--clean-final</span></code> uses unpaper to clean up pages before OCR and inserts the page into the final output.  You will want to review each page to ensure that unpaper did not remove something important.</li>
</ul>
<div class="section" id="ocr-and-correct-document-skew-crooked-scan">
<h3>OCR and correct document skew (crooked scan)<a class="headerlink" href="#ocr-and-correct-document-skew-crooked-scan" title="Permalink to this headline"></a></h3>
<div class="highlight-bash"><div class="highlight"><pre><span></span>ocrmypdf --deskew input.pdf output.pdf
</pre></div>
</div>
</div>
</div>
<div class="section" id="hot-watched-folders">
<h2>Hot (watched) folders<a class="headerlink" href="#hot-watched-folders" title="Permalink to this headline"></a></h2>
<p>To set up a &#8220;hot folder&#8221; that will trigger an OCR operation for every file inserted, use a program like Python <a class="reference external" href="https://pypi.python.org/pypi/watchdog">watchdog</a> (supports all major OS).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>apt-get install python-watchdog
</pre></div>
</div>
<p>watchdog installs the command line program <code class="docutils literal"><span class="pre">watchmedo</span></code>, which can be told to run <code class="docutils literal"><span class="pre">ocrmypdf</span></code> on any .pdf added to the current directory (<code class="docutils literal"><span class="pre">.</span></code>) and place the result in the previously created <code class="docutils literal"><span class="pre">out/</span></code> folder.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nb">cd</span> hot-folder
mkdir out
watchmedo shell-command <span class="se">\</span>
        --patterns<span class="o">=</span><span class="s2">&quot;*.pdf&quot;</span> <span class="se">\</span>
        --ignore-directories <span class="se">\</span>
        --command<span class="o">=</span><span class="s1">&#39;ocrmypdf &quot;${watch_src_path}&quot; &quot;out/${watch_src_path}&quot; &#39;</span> <span class="se">\</span>
        .  <span class="c1"># don&#39;t forget the final dot</span>
</pre></div>
</div>
<p>For more complex behavior you can write a Python script around to use the watchdog API.</p>
<p>On file servers, you could configure watchmedo as a system service so it will run all the time.</p>
<div class="section" id="caveats">
<h3>Caveats<a class="headerlink" href="#caveats" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">watchmedo</span></code> may not work properly on a networked file system, depending on the capabilities of the file system client and server.</li>
<li>This simple recipe does not filter for the type of file system event, so file copies, deletes and moves, and directory operations, will all be sent to ocrmypdf, producing errors in several cases. Disable your watched folder if you are doing anything other than copying files to it.</li>
<li>If the source and destination directory are the same, watchmedo may create an infinite loop.</li>
</ul>
</div>
</div>
<div class="section" id="batch-jobs">
<h2>Batch jobs<a class="headerlink" href="#batch-jobs" title="Permalink to this headline"></a></h2>
<p>Consider using the excellent <a class="reference external" href="https://www.gnu.org/software/parallel/">GNU Parallel</a> to apply OCRmyPDF to multiple files at once.</p>
<p>Both <code class="docutils literal"><span class="pre">parallel</span></code> and <code class="docutils literal"><span class="pre">ocrmypdf</span></code> will try to use all available processors. To maximize parallelism without overloading your system with processes, consider using <code class="docutils literal"><span class="pre">parallel</span> <span class="pre">-j</span> <span class="pre">2</span></code> to limit parallel to running two jobs at once.</p>
<p>This command will run all ocrmypdf all files named <code class="docutils literal"><span class="pre">*.pdf</span></code> in the current directory and write them to the previous created <code class="docutils literal"><span class="pre">output/</span></code> folder.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>parallel -j <span class="m">2</span> ocrmypdf <span class="s1">&#39;{}&#39;</span> <span class="s1">&#39;output/{}&#39;</span> ::: *.pdf
</pre></div>
</div>
<p>If you have thousands of files to work with, contact the author.</p>
</div>
</div>


           </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="security.html" class="btn btn-neutral float-right" title="PDF Security Issues" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="languages.html" class="btn btn-neutral" title="Installing additional language packs" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017, James R. Barlow.

    </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:'4.3.5',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true
        };
    </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>