//get file actual path
String filePath = Common.getFilePath(fileName);
// Create an extractor factory
var factory = new ExtractorFactory();
// Create an instance of PdfTextExtractor class
var extractor = new PdfTextExtractor(filePath);
//Set extraction mode to Fast text extraction
extractor.ExtractMode = ExtractMode.Simple;
// Iterate over all files in the portfolio
for (var i = 0; i < extractor.Entities.Count; i++)
{
// Print the name of a file
Console.WriteLine(extractor.Entities[i].Name);
// Open the stream of a file
using (var stream = extractor.Entities[i].OpenStream())
{
// Create the text extractor for a file
var entityExtractor = factory.CreateTextExtractor(stream);
// If a media type is supported
if (entityExtractor != null)
try
{
// Print the content of a file
Console.WriteLine(entityExtractor.ExtractAll());
}
finally
{
entityExtractor.Dispose();
}
}
}