This file is indexed.

/usr/share/doc/ocrmypdf/html/introduction.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
<!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>Introduction &mdash; 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="Release notes" href="release_notes.html"/>
        <link rel="prev" title="OCRmyPDF documentation" href="index.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 current"><a class="current reference internal" href="#">Introduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#about-ocr">About OCR</a></li>
<li class="toctree-l2"><a class="reference internal" href="#about-pdfs">About PDFs</a></li>
<li class="toctree-l2"><a class="reference internal" href="#about-pdf-a">About PDF/A</a></li>
<li class="toctree-l2"><a class="reference internal" href="#what-ocrmypdf-does">What OCRmyPDF does</a></li>
<li class="toctree-l2"><a class="reference internal" href="#why-you-shouldn-t-do-this-manually">Why you shouldn’t do this manually</a></li>
<li class="toctree-l2"><a class="reference internal" href="#limitations">Limitations</a></li>
<li class="toctree-l2"><a class="reference internal" href="#similar-programs">Similar programs</a></li>
<li class="toctree-l2"><a class="reference internal" href="#web-front-ends">Web front-ends</a></li>
</ul>
</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>
<li class="toctree-l1"><a class="reference internal" href="cookbook.html">Cookbook</a></li>
<li class="toctree-l1"><a class="reference internal" href="advanced.html">Advanced features</a></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> &raquo;</li>
        
      <li>Introduction</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/introduction.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="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h1>
<p>OCRmyPDF is a Python 3 package that adds OCR layers to PDFs.</p>
<div class="section" id="about-ocr">
<h2>About OCR<a class="headerlink" href="#about-ocr" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://en.wikipedia.org/wiki/Optical_character_recognition">Optical character recognition</a> is technology that converts images of typed or handwritten text, such as in a scanned document, to computer text that can be searched and copied.</p>
<p>OCRmyPDF uses <a class="reference external" href="https://github.com/tesseract-ocr/tesseract">Tesseract</a>, the best available open source OCR engine, to perform OCR.</p>
</div>
<div class="section" id="about-pdfs">
<span id="raster-vector"></span><h2>About PDFs<a class="headerlink" href="#about-pdfs" title="Permalink to this headline"></a></h2>
<p>PDFs are page description files that attempts to preserve a layout exactly. They  contain <a class="reference external" href="http://vector-conversions.com/vectorizing/raster_vs_vector.html">vector graphics</a> that can contain raster objects such as scanned images. Because PDFs can contain multiple pages (unlike many image formats) and can contain fonts and text, it is a good formats for exchanging scanned documents.</p>
<img alt="_images/bitmap_vs_svg.svg" src="_images/bitmap_vs_svg.svg" /><p>A PDF page might contain multiple images, even if it only appears to have one image.  Some scanners or scanning software will segment pages into monochromatic text and color regions for example, to improve the compression ratio and appearance of the page.</p>
<p>Rasterizing a PDF is the process of generating an image suitable for display or analyzing with an OCR engine.  OCR engines like Tesseract work with images, not vector objects.</p>
</div>
<div class="section" id="about-pdf-a">
<h2>About PDF/A<a class="headerlink" href="#about-pdf-a" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://en.wikipedia.org/wiki/PDF/A">PDF/A</a> is an ISO-standardized subset of the full PDF specification that is designed for archiving (the ‘A’ stands for Archive).  PDF/A differs from PDF primarily by omitting features that would make it difficult to read the file in the future, such as embedded Javascript, video, audio and references to external fonts.  All fonts and resources needed to interpret the PDF must be contained within it. Because PDF/A disables Javascript and other types of embedded content, it is probably more secure.</p>
<p>There are various conformance levels and versions, such as “PDF/A-2b”.</p>
<p>Generally speaking, the best format for scanned documents is PDF/A. Some governments and jurisdictions, US Courts in particular, <a class="reference external" href="https://pdfblog.com/2012/02/13/what-is-pdfa/">mandate the use of PDF/A</a> for scanned documents.</p>
<p>Since most people who scan documents are interested in reading them indefinitely into the future, OCRmyPDF generates PDF/A-2b by default.</p>
<p>PDF/A has a few drawbacks.  Some PDF viewers include an alert that the file is a PDF/A, which may confuse some users.  It also tends to produce larger files than PDF, because it embeds certain resources even if they are commonly available. PDF/A files can be digitally signed, but may not be encrypted, to ensure they can be read in the future.  Fortunately, converting from PDF/A to a regular PDF is trivial, and any PDF viewer can view PDF/A.</p>
</div>
<div class="section" id="what-ocrmypdf-does">
<h2>What OCRmyPDF does<a class="headerlink" href="#what-ocrmypdf-does" title="Permalink to this headline"></a></h2>
<p>OCRmyPDF analyzes each page of a PDF to determine the colorspace and resolution (DPI) needed to capture all of the information on that page without losing content.  It uses <a class="reference external" href="http://ghostscript.com/">Ghostscript</a> to rasterize the page, and then performs on OCR on the rasterized image to create an OCR “layer”. The layer is then grafted back onto the original PDF.</p>
<p>While one can use a program like Ghostscript or ImageMagick to get an image and put the image through Tesseract, that actually creates a new PDF and many details may be lost. OCRmyPDF can produce a minimally changed PDF as output.</p>
<p>OCRmyPDF also some image processing options like deskew which improve the appearance of files and quality of OCR. When these are used, the OCR layer is grafted onto the processed image instead.</p>
<p>By default, OCRmyPDF produces archival PDFs – PDF/A, which are a stricter subset of PDF features designed for long term archives. If regular PDFs are desired, this can be disabled with <code class="docutils literal"><span class="pre">--output-type</span> <span class="pre">pdf</span></code>.</p>
</div>
<div class="section" id="why-you-shouldn-t-do-this-manually">
<h2>Why you shouldn’t do this manually<a class="headerlink" href="#why-you-shouldn-t-do-this-manually" title="Permalink to this headline"></a></h2>
<p>A PDF is similar to an HTML file, in that it contains document structure along with images.  Sometimes a PDF does nothing more than present a full page image, but often there is additional content that would be lost.</p>
<p>A manual process could work like either of these:</p>
<ol class="arabic simple">
<li>Rasterize each page as an image, OCR the images, and combine the output into a PDF. This preserves the layout of each page, but resamples all images (possibly losing quality, increasing file size, introducing compression artifacts, etc.).</li>
<li>Extract each image, OCR, and combine the output into a PDF. This loses the context in which images are used in the PDF, meaning that cropping, rotation and scaling of pages may be lost. Some scanned PDFs use multiple images segmented into black and white, grayscale and color regions, with stencil masks to prevent overlap, as this can enhance the appearance of a file while reducing file size. Clearly, reassembling these images will be easy. This also loses and text or vector art on any pages in a PDF with both scanned and pure digital content.</li>
</ol>
<p>In the case of a PDF that is nothing other than a container of images (no rotation, scaling, cropping, one image per page), the second approach can be lossless.</p>
<p>OCRmyPDF uses several strategies depending on input options and the input PDF itself, but generally speaking it rasterizes a page for OCR and then grafts the OCR back onto the original. As such it can handle complex PDFs and still preserve their contents as much as possible.</p>
</div>
<div class="section" id="limitations">
<h2>Limitations<a class="headerlink" href="#limitations" title="Permalink to this headline"></a></h2>
<p>OCRmyPDF is limited by the Tesseract OCR engine.  As such it experiences these limitations, as do any other programs that rely on Tesseract:</p>
<ul class="simple">
<li>The OCR is not as accurate as commercial solutions such as Abbyy.</li>
<li>It is not capable of recognizing handwriting.</li>
<li>It may find gibberish and report this as OCR output.</li>
<li>If a document contains languages outside of those given in the <code class="docutils literal"><span class="pre">-l</span> <span class="pre">LANG</span></code> arguments, results may be poor.</li>
<li>It is not always good at analyzing the natural reading order of documents. For example, it may fail to recognize that a document contains two columns and join text across the columns.</li>
<li>Poor quality scans may produce poor quality OCR. Garbage in, garbage out.</li>
<li>PDFs that use transparent layers are not currently checked in the test suite, so they may not work correctly.</li>
</ul>
<p>OCRmyPDF is also limited by the PDF specification:</p>
<ul class="simple">
<li>PDF encodes the position of text glyphs but does not encode document structure.  There is no markup that divides a document in sections, paragraphs, sentences, or even words (since blank spaces are not represented). As such all elements of document structure including the spaces between words must be derived heuristically.  Some PDF viewers do a better job of this than others.</li>
<li>Because some popular open source PDF viewers have a particularly hard time with spaces betweem words, OCRmyPDF appends a space to each text element as a workaround. While this mixes document structure with graphical information that ideally should be left to the PDF viewer to interpret, it improves compatibility with some viewers and does not cause problems for better ones.</li>
</ul>
<p>Ghostscript also imposes some limitations:</p>
<ul class="simple">
<li>PDFs containing JBIG2-encoded content will be converted to CCITT Group4 encoding, which has lower compression ratios, if Ghostscript PDF/A is enabled.</li>
<li>PDFs containing JPEG 2000-encoded content will be converted to JPEG encoding, which may introduce compression artifacts, if Ghostscript PDF/A is enabled.</li>
<li>Ghostscript may transcode grayscale and color images, either lossy to lossless or lossless to lossy, based on an internal algorithm. This behavior can be suppressed by setting <code class="docutils literal"><span class="pre">--pdfa-image-compression</span></code> to <code class="docutils literal"><span class="pre">jpeg</span></code> or <code class="docutils literal"><span class="pre">lossless</span></code> to set all images to one type or the other. Ghostscript has no option to maintain the input image’s format.</li>
</ul>
<p>OCRmyPDF is currently not designed to be used as a Python API; it is designed to be run as a command line tool. <code class="docutils literal"><span class="pre">import</span> <span class="pre">ocrmypf</span></code> currently attempts to process the command line on <code class="docutils literal"><span class="pre">sys.argv</span></code> at import time so it has side effects that will interfere with its use as a package. The API it presents should not be considered stable.</p>
</div>
<div class="section" id="similar-programs">
<h2>Similar programs<a class="headerlink" href="#similar-programs" title="Permalink to this headline"></a></h2>
<p>To the author’s knowledge, OCRmyPDF is the most feature-rich and thoroughly tested command line OCR PDF conversion tool. If it does not meet your needs, contributions and suggestions are welcome. If not, consider one of these similar open source programs:</p>
<ul class="simple">
<li>pdf2pdfocr</li>
<li>pdfsandwich</li>
<li>pypdfocr</li>
<li>pdfbeads</li>
</ul>
</div>
<div class="section" id="web-front-ends">
<h2>Web front-ends<a class="headerlink" href="#web-front-ends" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a class="reference external" href="https://github.com/janis91/ocr">Nextcloud OCR</a> is a free software plugin for the Nextcloud private cloud software</li>
<li><a class="reference external" href="https://github.com/sseemayer/OCRmyPDF-web">OCRmyPDF-web</a>, a micro web-frontend for OCRmyPDF (third-party, not actively maintained)</li>
</ul>
<p>Bear in mind that OCRmyPDF is not designed to be secure against malware-bearing PDFs (see <a href="#id1"><span class="problematic" id="id2">`Using OCRmyPDF online`_</span></a>).</p>
</div>
</div>


           </div>
           <div class="articleComments">
            
           </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="release_notes.html" class="btn btn-neutral float-right" title="Release notes" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="index.html" class="btn btn-neutral" title="OCRmyPDF documentation" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; 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>