Program.cs
上传用户:towway102
上传日期:2022-07-04
资源大小:4k
文件大小:1k
- using System;
- using System.IO;
- using org.pdfbox.pdmodel;
- using org.pdfbox.util;
- namespace Pdf2Text
- {
- class Program
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- DateTime start = DateTime.Now;
- if (args.Length < 2)
- {
- Console.WriteLine("Usage: PDF2TEXT <input filename (PDF)> <output filename (text)>");
- return;
- }
- using (StreamWriter sw = new StreamWriter(args[1]))
- {
- sw.WriteLine(parseUsingPDFBox(args[0]));
- }
- Console.WriteLine("Done. Took " + (DateTime.Now - start));
- // Console.ReadLine();
- }
- private static string parseUsingPDFBox(string input)
- {
- PDDocument doc = PDDocument.load(input);
- PDFTextStripper stripper = new PDFTextStripper();
- return stripper.getText(doc);
- }
- }
- }