Created
February 9, 2018 15:25
-
-
Save foyzulkarim/f8f6de7c921f7428bfc7ca9661289345 to your computer and use it in GitHub Desktop.
One of my clients who is currently using BizBook, used Wave for some months, but while they grew bigger, wave stopped supporting to download the invoices as a bulk excel or csv. So, when they decided to jump into BizBook, then they had to export their all existing data into my system. Since the wave didn’t allow csv / excel anymore, so I had no …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static IEnumerable<string> GetTextFromPDF(string invoicePdf) | |
{ | |
var fromPdf = new List<string>(); | |
using (PdfReader reader = new PdfReader(invoicePdf)) | |
{ | |
for (int i = 1; i <= reader.NumberOfPages; i++) | |
{ | |
string value = PdfTextExtractor.GetTextFromPage(reader, i); | |
List<string> list = value.Split(new[] { "\n" }, StringSplitOptions.None).ToList(); | |
list.RemoveAll(Match); | |
int findIndex = list.FindIndex(x => x.StartsWith("Products Quantity Price Amount")); | |
if (findIndex > 0) | |
{ | |
List<string> phoneList = list[findIndex - 1].Split( | |
new string[] { " " }, | |
StringSplitOptions.RemoveEmptyEntries).ToList(); | |
if (phoneList.Count > 0) | |
{ | |
list[findIndex - 1] = phoneList[0]; | |
} | |
} | |
string joined = string.Join("\n", list); | |
fromPdf.Add(joined); | |
} | |
} | |
return fromPdf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment