public string GetFileFormat(string path, string statementType, BankStatementFields bankStatementFields) { var fileName = _fileService.GetFileName(path); var fileExtension = _fileService.GetFileExtension(path); var parentFolder = _fileService.GetParent(path); var originalDocumentSubdirectory = _fileService.GetOriginalDocumentSubdirectory(parentFolder); string originalDocumentSubdirectoryFileName = Path.Combine(originalDocumentSubdirectory.FullName, $"{fileName}{fileExtension}"); _fileService.CopyFile(path, originalDocumentSubdirectoryFileName, true); var newFileName = $"{parentFolder.Name} {statementType} {bankStatementFields.AccountNumber} {bankStatementFields.DateRange}"; return(Path.Combine(parentFolder.FullName, $"{newFileName}{fileExtension}")); }
public BankStatementFields ExtractText(string filePath) { var bankStatementFields = new BankStatementFields(); if (!FileService.Exists(filePath)) { throw new FileNotFoundException($"Cannot find file in in filepath {filePath}"); } var pdfDocument = new PdfDocument(new PdfReader(filePath).SetUnethicalReading(true)); bankStatementFields.AccountNumber = GetAccountNumber(pdfDocument); bankStatementFields.DateRange = GetDateRange(pdfDocument); pdfDocument.Close(); return(bankStatementFields); }