public ActionResult FindPDFCorruption() { FindPDFCorruptionMessage message = new FindPDFCorruptionMessage(); message.Message = string.Empty; return(View("FindPDFCorruption", message)); }
public ActionResult FindPDFCorruption(string FindCorruption) { string dataPath = _hostingEnvironment.WebRootPath + @"/PDF/"; FindPDFCorruptionMessage message = new FindPDFCorruptionMessage(); //Read the certificate file. FileStream pdfFile = new FileStream(dataPath + @"CorruptedDocument.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //Create a new instance for the PDF analyzer. PdfDocumentAnalyzer analyzer = new PdfDocumentAnalyzer(pdfFile); //Get the syntax errors. SyntaxAnalyzerResult result = analyzer.AnalyzeSyntax(); //Check whether the document is corrupted or not. if (result.IsCorrupted) { StringBuilder builder = new StringBuilder(); builder.AppendLine("The PDF document is corrupted."); int count = 1; foreach (PdfException exception in result.Errors) { builder.AppendLine(count++.ToString() + ": " + exception.Message); } message.Message = builder.ToString(); } return(View("FindPDFCorruption", message)); }
public ActionResult FindPDFCorruption(string InsideBrowser) { FindPDFCorruptionMessage message = new FindPDFCorruptionMessage(); ////Create a new instance for the PDF analyzer. FileStream fileStreamInput = new FileStream(ResolveApplicationDataPath("CorruptedDocument.pdf"), FileMode.Open, FileAccess.Read); PdfDocumentAnalyzer analyzer = new PdfDocumentAnalyzer(fileStreamInput); StringBuilder builder = new StringBuilder(); //Get the syntax errors. SyntaxAnalyzerResult result = analyzer.AnalyzeSyntax(); //Check whether the document is corrupted or not. if (result.IsCorrupted) { builder.AppendLine("The PDF document is corrupted."); int count = 1; foreach (PdfException exception in result.Errors) { builder.AppendLine(count++.ToString() + ": " + exception.Message); } message.Message = builder.ToString(); } return(View("FindPDFCorruption", message)); }