コード例 #1
0
        private PdfResult Execute(byte[] bytes, DateTime start)
        {
            try
            {
                var result = _extractPdf.Execute(bytes);

                var content = _parser.Execute(result);
                return(PdfResult.CreateSuccesResult(DateTime.Now.Subtract(start), content));
            }
            catch (Exception e)
            {
                return(PdfResult.CreateErrorResult(DateTime.Now.Subtract(start), e));
            }
        }
コード例 #2
0
        /// <summary>
        /// Method to load the pdf, and extract the text from it.
        /// </summary>
        /// <param name="filePathToPdf">File path</param>
        /// <returns></returns>
        public PdfResult OcrPdf(string filePathToPdf)
        {
            var start = DateTime.Now;

            try
            {
                if (!File.Exists(filePathToPdf))
                {
                    throw new FileNotFoundException("", filePathToPdf);
                }
                return(Execute(File.ReadAllBytes(filePathToPdf), start));
            }
            catch (Exception e)
            {
                return(PdfResult.CreateErrorResult(DateTime.Now.Subtract(start), e));
            }
        }