Как искать кириллицу в PDF с помощью PDF Clown - PullRequest
0 голосов
/ 17 октября 2019

Я пытаюсь программно найти русскоязычный pdf-файл для поиска строки, используя PDF Clown , например:

var FilePath = @"‪C:\Users\Yvoloshin\source\repos\SearchPdf\Газета «Красная Звезда» №001 от 01 января 1942 года.pdf";
org.pdfclown.files.File file = new org.pdfclown.files.File(FilePath);

// Define the text pattern to look for
var pattern = new Regex("К новым", RegexOptions.IgnoreCase);

// Instantiate the extractor
TextExtractor textExtractor = new TextExtractor(true, true);

foreach (var page in file.Document.Pages)
{
// Extract the page text
var textStrings = textExtractor.Extract(page);

// Find the text pattern matches
var matches = pattern.Matches(TextExtractor.ToString(textStrings));
Console.WriteLine(matches);
Console.ReadLine();
}

Когда я запускаю это, я получаю эту ошибку:

Unhandled Exception: System.NotSupportedException: The given path's format is not supported.
   at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   at org.pdfclown.files.File..ctor(String path)

Это проблема с PDF Clown, не настроенным для кириллических шрифтов, или проблема в другом месте? Я использую Visual Studio 2017 и .NET 4.8.

...