title: How is hidden text stored in OCR-enhanced PDF files
body: <p>// EDIT 26.03.2018 - Who wants to continue my work can have a look on my source-files <a href="https://github.com/n0l0cale/ocr-sampledata" rel="nofollow noreferrer">https://github.com/n0l0cale/ocr-sampledata</a></p>
  
  <p>I'm actually looking for some details about PDF Files. It's most important for me that the files will be usable for a very long time and if possible the OCR should be automatically applied for new files (which seems to be not really possible with Adobe Acrobat...).</p>
  
  <p>For that I've been looking for different solutions how to OCR my PDF Files. I found three candidates which seems to be doing what they should do... (more or less). But all three variants have their pro&amp;cons... But there seem to be different approaches how to store data in PDF Files.... for all three Variants... Let me explain:</p>
  
  <ul>
  <li><p>a File OCRed with Adobe Acrobat:</p>
  
  <p><a href="https://github.com/n0l0cale/ocr-sampledata/blob/master/A4%20sample_ACROBAT.pdf" rel="nofollow noreferrer">https://github.com/n0l0cale/ocr-sampledata/blob/master/A4%20sample_ACROBAT.pdf</a></p>
  
  <p>results in a file that Acrobat is able to open in one step (no preloading of any background layer) and after a preflight-script I'm able to see the text which is stored hidden:</p>
  
  <p><img src="https://i.stack.imgur.com/2Yx0v.png" alt="Preflight analysed layers"></p></li>
  <li><p>a File OCRed with Abby Finereader:</p>
  
  <p><a href="https://github.com/n0l0cale/ocr-sampledata/blob/master/A4%20sample_ABBY.pdf" rel="nofollow noreferrer">https://github.com/n0l0cale/ocr-sampledata/blob/master/A4%20sample_ABBY.pdf</a></p>
  
  <p>does not seem suitable for the default adobe preflight-script as it does not display any additional layers:</p>
  
  <p><img src="https://i.stack.imgur.com/Wo6uT.jpg" alt="Preflight analysed layers"></p>
  
  <p>But far as I was able to reproduce these Files seems to have a Background-Text-Layer, which contains the OCRed Text, which is the underlying layer for the Image that is shown to the user at the end. Unfortunately this seems to be loaded separately and this is confusing while opening the file with Adobe Acrobat...</p></li>
  <li><p>a File OCRed with Tesseract 4 (Alpha):</p>
  
  <p><a href="https://github.com/n0l0cale/ocr-sampledata/blob/master/A4%20sample_TESSERACT_oem2.pdf" rel="nofollow noreferrer">https://github.com/n0l0cale/ocr-sampledata/blob/master/A4%20sample_TESSERACT_oem2.pdf</a></p>
  
  <p>is also doing some weird magic with the hidden text part:</p>
  
  <p><img src="https://i.stack.imgur.com/vivC4.png" alt="Preflight analysed layers"></p></li>
  </ul>
  
  <p>But in all three cases I'm able to search for words in the files and see the text using "Remove hidden information" and selecting "hidden text":</p>
  
  <p><img src="https://i.stack.imgur.com/wG90n.jpg" alt="View of &quot;Remove hidden text&quot; function in Adobe Acrobat DC Pro"></p>
  
  <p>I'm seriously confused.... Does anyone know how these programs are storing their hidden text information really?</p>
  
  <p>S.</p>
  
  <p>P.S.: For those wondering what this ominous preflight script is: <a href="https://theblog.adobe.com/hidden-gems-in-acrobat-dc-how-to-optimize-hidden-ocr-text/" rel="nofollow noreferrer">https://theblog.adobe.com/hidden-gems-in-acrobat-dc-how-to-optimize-hidden-ocr-text/</a></p>