ImageExtractTest.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using ComPDFKit.PDFDocument;
  2. using System;
  3. using System.IO;
  4. namespace ImageExtractTest
  5. {
  6. internal class ImageExtractTest
  7. {
  8. private static string outputPath =Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))) ?? string.Empty, "Output", "CS");
  9. static void Main(string[] args)
  10. {
  11. #region Perparation work
  12. Console.WriteLine("Running Bookmark test sample…\r\n");
  13. SDKLicenseHelper.LicenseVerify();
  14. CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
  15. if (!Directory.Exists(outputPath))
  16. {
  17. Directory.CreateDirectory(outputPath);
  18. }
  19. #endregion
  20. #region Sample 1: Extract image
  21. ExtractImage(document);
  22. document.Release();
  23. Console.WriteLine("--------------------");
  24. #endregion
  25. Console.WriteLine("Done");
  26. Console.WriteLine("--------------------");
  27. Console.ReadLine();
  28. }
  29. /// <summary>
  30. /// Extract all images from document
  31. /// </summary>
  32. /// <param name="document">Regular documet with some picture</param>
  33. static private void ExtractImage(CPDFDocument document)
  34. {
  35. document.ExtractImage("1-5", outputPath);
  36. }
  37. }
  38. }