Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foyzulkarim/f8f6de7c921f7428bfc7ca9661289345 to your computer and use it in GitHub Desktop.
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 …
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