Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using iTextSharp.text.pdf;
  2. using iTextSharp.text.pdf.parser;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10.  
  11. namespace Bio_Pdf_Extractor
  12. {
  13. class Program
  14. {
  15.  
  16. public static class PdfExtract
  17. {
  18. public static string PdfText(string path, int page)
  19. {
  20. PdfReader reader = new PdfReader(path);
  21. string text = string.Empty;
  22. text += PdfTextExtractor.GetTextFromPage(reader, page);
  23. reader.Close();
  24. return text;
  25. }
  26. }
  27.  
  28.  
  29. static void Main(string[] args)
  30. {
  31. string bio_file = @"C:\Users\hasan.canim\Desktop\Wilfried\";
  32. string[] files = Directory.GetFiles(bio_file, "*.pdf", SearchOption.AllDirectories);
  33.  
  34. foreach(string file in files) // Each file in the directory
  35. {
  36. var pdfString = PdfExtract.PdfText(file, 1);
  37. Console.WriteLine(pdfString);
  38. }
  39. Console.ReadKey();
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement