2 votes

Umbraco.ExaminePDF

Umbraco.ExaminePDF

PDF indexing support in UmbracoExamine using PdfPig

Installation

Install with Nuget:

dotnet add package Umbraco.ExaminePDF

You will then have a new Examine index called "PDFIndex" available.

Multi index searchers

To use the MultiSearcher in V8, you can instantiate it when needed like:

using(var multiSearcher = new MultiIndexSearcher("MultiSearcher", new IIndex[] { 
    externalIndex, 
    pdfIndex 
}))
{
 ...
};

Or you can register a multi-index searcher with the ExamineManager on startup like:

[ComposeAfter(typeof(ExaminePdfComposer))] //this must execute after the ExaminePdfComposer composer
public class MyComposer : ComponentComposer<MyComponent>, IUserComposer
{
}

public class MyComponent : IComponent
{
    private readonly IExamineManager _examineManager;

    public MyComponent(IExamineManager examineManager)
    {
        _examineManager = examineManager;
    }

    public void Initialize()
    {
        //Get both the external and pdf index
        if (_examineManager.TryGetIndex(Constants.UmbracoIndexes.ExternalIndexName, out var externalIndex)
            && _examineManager.TryGetIndex(PdfIndexConstants.PdfIndexName, out var pdfIndex))
        {
            //register a multi searcher for both of them
            var multiSearcher = new MultiIndexSearcher("MultiSearcher", new IIndex[] { externalIndex, pdfIndex });
            _examineManager.AddSearcher(multiSearcher);
        }
    }

    public void Terminate() { }
}

With this approach, the multi searcher will show up in the Examine dashboard and it can be resolved from the ExamineManager like:

if (_examineManager.TryGetSearcher("MultiSearcher", out var searcher))
{
    //TODO: use the `searcher` to search
}

License

The source code for UmbracoExamine.PDF is licensed under the MIT license.

NuGet install instructions for Umbraco 9+

dotnet add package Umbraco.ExaminePDF

Package owner

Bjarke Berg

Bjarke Berg

Bjarke has 265 karma points
hq

Package Information

  • Package owner: Bjarke Berg
  • Created: 08/07/2021
  • Current version 9.0.0-beta001
  • License MIT
  • Downloads on Our: 0
  • Downloads on NuGet: 46.6K
  • Total downloads : 46.6K

External resources