public void OCR_PDF_Extract(string PDFType) { //string PDFLoation = ScenarioContext.Current["PDFpath"].ToString(); string PDFLoation = "C:\\demo"; 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 + PDFType + "__Page -{0}.{1}"; string adda = "\\SPLIT"; string dataloc = PDFLoation + adda + "__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 + "\\" + PDFType + "__Page -{0}.{1}"; Ocr.ConvertorFromPdFtoData(concatDes, dataloc); //return dataloc; } }
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); }