CPDFConverter.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // CPDFConverter.h
  3. // ComPDFKit_Conversion
  4. //
  5. // Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
  6. //
  7. // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  8. // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  9. // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  10. // This notice may not be removed from this file.
  11. //
  12. #import <Foundation/Foundation.h>
  13. #import <ComPDFKit_Conversion/CPDFConvertOptions.h>
  14. extern NSErrorDomain const CPDFConverterErrorDomain;
  15. NS_ERROR_ENUM(CPDFConverterErrorDomain) {
  16. CPDFConverterSuccess = 0, // Success
  17. CPDFConverterEncryptError = 1, // Password required or incorrect password.
  18. CPDFConverterPermissionError = 2, // The license doesn't allow the permission.
  19. CPDFConverterMallocError = 3, // Malloc failure.
  20. CPDFConverterUnknownError = 4, // Unknown error in processing conversion.
  21. CPDFConverterPDFUnknownError = 5, // Unknown error in processing PDF.
  22. CPDFConverterPDFFileError = 6, // File not found or could not be opened.
  23. CPDFConverterPDFFormatError = 7, // File not in PDF format or corrupted.
  24. CPDFConverterPDFSecurityError = 8, // Unsupported security scheme.
  25. CPDFConverterPDFPageError = 9 // Page not found or content error.
  26. };
  27. @class CPDFConverter;
  28. /**
  29. * The delegate for the CPDFConverter object.
  30. */
  31. @protocol CPDFConverterDelegate <NSObject>
  32. @optional
  33. /**
  34. * Called when a conversion operation begins.
  35. */
  36. - (void)converter:(CPDFConverter *)converter didStartConvert:(NSError *)error;
  37. /**
  38. * Called when a conversion operation finishes.
  39. */
  40. - (void)converter:(CPDFConverter *)converter didEndConvert:(NSError *)error;
  41. /**
  42. * Called when a conversion operation finishes working on a page in a document.
  43. */
  44. - (void)converter:(CPDFConverter *)converter pageIndex:(NSUInteger)index pageCount:(NSUInteger)count;
  45. @end
  46. /**
  47. * This is the base class for all conversion operations.
  48. *
  49. * This is the base class for all converters. A CPDFConverter object by itself is not useful, only subclasses (like CPDFConverterWord, CPDFConverterPPT) are interesting.
  50. */
  51. @interface CPDFConverter : NSObject
  52. /**
  53. * Initializes a CPDFConverter object with the contents at the specified URL.
  54. */
  55. - (instancetype)initWithURL:(NSURL *)url password:(NSString *)password;
  56. /**
  57. * The object acting as the delegate for the CPDFConverter object.
  58. *
  59. * @see CPDFConverterDelegate
  60. */
  61. @property (nonatomic,assign) id<CPDFConverterDelegate> delegate;
  62. /**
  63. * Returns a Boolean value indicating whether a conversion operation is in progress.
  64. */
  65. @property (nonatomic,readonly) BOOL isConverting;
  66. /**
  67. * Starts convert the specified source file into the specified file.
  68. *
  69. * @param filePath String of the full path to the specified file.
  70. * @param pageIndexs The page number range.
  71. */
  72. - (void)convertToFilePath:(NSString *)filePath pageIndexs:(NSArray *)pageIndexs options:(CPDFConvertOptions *)options;
  73. /**
  74. * Cancels the conversion task.
  75. */
  76. - (void)cancel;
  77. @end