1

Sitecore 10.2 running in Docker Desktop for Windows

While crawling content I started seeing tons of errors messages in the Sitecore log:

2080 13:47:43 ERROR DefaultMediaItemTextExtractor: Cannot extract content from media item with id '{59AB8B22-2179-48D5-AEF4-068DF0DED0E8}'.
Exception: PdfSharp.Pdf.IO.PdfReaderException
Message: The PDF document is protected with an encryption not supported by PDFsharp.
Source: PdfSharp
   at PdfSharp.Pdf.Security.PdfStandardSecurityHandler.ValidatePassword(String inputPassword)
   at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider)
   at PdfSharp.Pdf.IO.PdfReader.Open(String path, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider provider)
   at Sitecore.ContentSearch.ContentExtraction.Readers.PdfSharpReader.ReadAll(String filePath)
   at Sitecore.ContentSearch.ContentExtraction.Common.DefaultMediaItemTextExtractor.ExtractTextFromMedia(MediaItem mediaItem)

What makes this even more strange is that {59AB8B22-2179-48D5-AEF4-068DF0DED0E8} represents an item of template type /sitecore/templates/Foundation/Experience Accelerator/Upgrade/Upgrade Script.

Is there a recommended solution to address this error?

Docker Image Solution?

One thing I did try, thinking that these were PDFS, was install the Adobe IFilter in the container.

Added the following to my CM Dockerfile:

COPY .\PDFFilter64installer.msi C:\install\
RUN Start-Process -FilePath 'msiexec.exe' -ArgumentList '/i', 'C:\\install\\PDFFilter64installer.msi', '/quiet', '/norestart' -NoNewWindow -Wait; `
    Remove-Item -Path 'C:\\install' -Recurse -Force;

Installer downloaded from Adobe's FTP site.

Then I patched the mediaFileTextExtractor:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
  <sitecore role:require="Standalone or ContentManagement or ContentDelivery">
    <contentSearch>
      <indexConfigurations>
        <contentExtraction>
          <mediaFileTextExtractor>
            <patch:delete />
          </mediaFileTextExtractor>
          <mediaFileTextExtractor type="Sitecore.ContentSearch.ContentExtraction.IFilter.IFilterMediaFileTextExtractor, Sitecore.ContentSearch.ContentExtraction"/>
        </contentExtraction>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

Related links

Update

While this may not be the right solution for everyone, I was able to disable this functionality by using the following patch:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/"  xmlns:search="http://www.sitecore.net/xmlconfig/search/">
  <sitecore role:require="Standalone or ContentManagement or ContentDelivery">
    <!-- Save time by not extracting content. -->
    <contentSearch>
      <indexConfigurations>
        <defaultSolrIndexConfiguration search:require="solr">
          <mediaIndexing>
            <mimeTypes>
              <includes>
                <patch:delete />
              </includes>
              <includes>
                <mimeType type="Sitecore.ContentSearch.ComputedFields.MediaItemHtmlTextExtractor, Sitecore.ContentSearch">text/html</mimeType>
                <mimeType>text/plain</mimeType>
              </includes>
            </mimeTypes>
            <extensions>
              <includes>
                <patch:delete />
              </includes>
              <includes/>
            </extensions>
          </mediaIndexing>
        </defaultSolrIndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

Turns out that some of these items were from custom templates for media items which do not have associated blob data. Sitecore has no way to ignore content extraction based on template ID, hence the errors.

1 Answer 1

3
  1. I think that your Upgrade Script item is not PDF file. So, first you should figure out why it is recognized as a PDF. Default Sitecore media content extractor works in the following way:
  • item should be indexed;
  • content extractor tries to get values of following item fields: Mime Type and Extension (mime type has a higher priority);
  • content extractor parses <mediaIndexing> node (default configuration is in Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config) and tries to match value from previous step to corresponding extractor (ComputeFieldValue implementation).

It seems that your item has Extention field which value is in the list of extensions -> includes (check your includes/excludes nodes configuration).

  1. If your item really has PDF content and you want to extract text:
  • by default Sitecore uses PDFSharp library for content extraction, but it is very primitive and can extract text only from limited PDFs files (without any postprocessing/scans/etc.). Your issue is very common and it is error/limitation of PDFSharp itself;
  • if you want to use iFilter instead of PDFSharp: the simplest way is to enable App_Config\Include\Examples\Sitecore.ContentSearch.ContentExtraction.IFilter.config.example config. It seems that your patch is not correct and you have erased Sitecore.ContentSearch.ContentExtraction.Readers.DefaultReaderFactory, but I`m not sure without seeing all configs.
  • iFilter is also not the best option and is very slow (I think it does not help in your situation). If you need smart PDF recognition - take a look at TikaOnDotnet (good sitecore module is https://github.com/michaelthyregod/Contrib.Sitecore.ContentSearch/tree/master/src/Contrib.Sitecore.ContentSearch.TikaOnDotnet). P.S.: if you need OCR support to extract text from scanned PDFs, take a look at my Tesseract module for sitecore https://github.com/x3mxray/Tesseract.Sitecore.ContentSearch)
1
  • I imagine we did not experience the issue in 9.3 as DefaultMediaItemTextExtractor doesn't exist. Commented Apr 27, 2022 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.