public ActionResult ExtractMetadata([FromBody] string fileName) { List <string> extractedText = new List <string>(); ExtractorFactory factory = new ExtractorFactory(); string path = Server.MapPath("../App_Data//Uploads//" + fileName); try { MetadataCollection metadata = factory.ExtractMetadata(path); if (metadata == null) { extractedText.Add("The document format is not supported"); } foreach (string key in metadata.Keys) { extractedText.Add(string.Format("{0} = {1}", key, metadata[key])); } } catch (Exception ex) { extractedText.Add(ex.Message); } return(Json(extractedText, JsonRequestBehavior.AllowGet)); }
public static void UsingExtractorFactory(string fileName) { //ExStart:UsingExtractorFactory //get file actual path String filePath = Common.getFilePath(fileName); ExtractorFactory factory = new ExtractorFactory(); //ExtractMetadata methods in ExtractorFactory class are marked as Obsolete from version 17.03 onwards(use Extractor class instead). MetadataCollection metadata = factory.ExtractMetadata(filePath); if (metadata == null) { Console.WriteLine("The document format is not supported"); } foreach (string key in metadata.Keys) { Console.WriteLine(string.Format("{0} = {1}", key, metadata[key])); } //ExEnd:UsingExtractorFactory }