123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using ComPDFKit.PDFDocument;
- using System;
- using System.IO;
- namespace TextExtractTest
- {
- internal class TextExtractTest
- {
- static private string outputPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))) + "\\Output\\TextExtract";
- static void Main(string[] args)
- {
- #region Perparation work
- Console.WriteLine("Running PDFPage test sample…\r\n");
- SDKLicenseHelper.LicenseVerify();
- CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
- if (!Directory.Exists(outputPath))
- {
- Directory.CreateDirectory(outputPath);
- }
- #endregion
- if (PDFToText(document))
- {
- Console.WriteLine("PDF to text done.");
- }
- else
- {
- Console.WriteLine("PDF to text failed.");
- }
- Console.WriteLine("--------------------");
- Console.WriteLine("Done!");
- Console.WriteLine("--------------------");
- Console.ReadLine();
- }
- //
- static private bool PDFToText(CPDFDocument document)
- {
- string path = outputPath + "//PDFToText.txt";
- if (!document.PdfToText("1-" + document.PageCount.ToString(), path))//Page ranges are counted from 1
- {
- return false;
- }
- Console.WriteLine("Browse the generated file in " + path);
- return true;
- }
- }
- }
|