public string ReadPDF(string PDFType, string Page, string Xpath) { string PDFLoation = ScenarioContext.Current["PDFpath"].ToString(); string newfilename = getLatestfilename(PDFLoation); string sValue = null; if (newfilename.Contains("_")) { string TrimNewfile = newfilename.Substring(newfilename.LastIndexOf('_') + 1).ToString(); var directory = new DirectoryInfo(PDFLoation); string concatSource = PDFLoation + "\\" + TrimNewfile; string concatDes = PDFLoation + "\\" + PDFType + "_" + TrimNewfile; Thread.Sleep(3000); File.Move(concatSource, concatDes); string dataloc = PDFLoation + "Page -{0}.{1}"; Ocr.ConvertorFromPdFtoData(concatDes, dataloc); //return dataloc; } else { string concatSource = PDFLoation + "\\" + newfilename; string concatDes = PDFLoation + "\\" + PDFType + "_" + newfilename; Thread.Sleep(3000); File.Move(concatSource, concatDes); string dataloc = PDFLoation + "\\" + "Page -{0}.{1}"; Ocr.ConvertorFromPdFtoData(concatDes, dataloc); //return dataloc; } if (Xpath.StartsWith("Line") || Xpath.StartsWith("word")) { string hhh = Ocr.ReadImage(PDFLoation, PDFType, Page, Xpath); sValue = hhh; } else { string hhh = Ocr.ReadImageParagraph(PDFLoation, PDFType, Page, Xpath); sValue = hhh; } return(sValue); }
public static string OCR_PDF_READ_NO_Space(string PDFType, string Page, string Xpath) { //string PDFLoation = ScenarioContext.Current["PDFpath"].ToString(); string PDFLoation = "C:\\demo"; string newfilename = getLatestfilename(PDFLoation); string sValue = null; if (Xpath.StartsWith("line") || Xpath.StartsWith("word")) { string hhh = Ocr.ReadImage(PDFLoation, PDFType, Page, Xpath); sValue = Regex.Replace(hhh, @"(°)", ""); } else { string hhh = Ocr.ReadImageParagraph(PDFLoation, PDFType, Page, Xpath); sValue = Regex.Replace(hhh, @"(°)", ""); } return(sValue); }