CPDFConverter.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. CPDFConverterEncryptError = 1, // Password required or incorrect password.
  17. CPDFConverterPermissionError = 2, // The license doesn't allow the permission.
  18. CPDFConverterMallocError = 3, // Malloc failure.
  19. CPDFConverterUnknownError = 4, // Unknown error in processing conversion.
  20. CPDFConverterPDFUnknownError = 5, // Unknown error in processing PDF.
  21. CPDFConverterPDFFileError = 6, // File not found or could not be opened.
  22. CPDFConverterPDFFormatError = 7, // File not in PDF format or corrupted.
  23. CPDFConverterPDFSecurityError = 8, // Unsupported security scheme.
  24. CPDFConverterPDFPageError = 9 // Page not found or content error.
  25. };
  26. @class CPDFConverter;
  27. /**
  28. * The delegate for the CPDFConverter object.
  29. */
  30. @protocol CPDFConverterDelegate <NSObject>
  31. @optional
  32. /**
  33. * Called when a conversion operation begins.
  34. */
  35. - (void)converter:(CPDFConverter *)converter didStartConvert:(NSError *)error;
  36. /**
  37. * Called when a conversion operation finishes.
  38. */
  39. - (void)converter:(CPDFConverter *)converter didEndConvert:(NSError *)error;
  40. /**
  41. * Called when a conversion operation finishes working on a page in a document.
  42. */
  43. - (void)converter:(CPDFConverter *)converter pageIndex:(NSUInteger)index pageCount:(NSUInteger)count;
  44. @end
  45. /**
  46. * This is the base class for all conversion operations.
  47. *
  48. * This is the base class for all converters. A CPDFConverter object by itself is not useful, only subclasses (like CPDFConverterWord, CPDFConverterPPT) are interesting.
  49. */
  50. @interface CPDFConverter : NSObject
  51. /**
  52. * Initializes a CPDFConverter object with the contents at the specified URL.
  53. */
  54. - (instancetype)initWithURL:(NSURL *)url password:(NSString *)password;
  55. /**
  56. * The object acting as the delegate for the CPDFConverter object.
  57. *
  58. * @see CPDFConverterDelegate
  59. */
  60. @property (nonatomic,assign) id<CPDFConverterDelegate> delegate;
  61. /**
  62. * Returns a Boolean value indicating whether a conversion operation is in progress.
  63. */
  64. @property (nonatomic,readonly) BOOL isConverting;
  65. /**
  66. * Starts convert the specified source file into the specified file.
  67. *
  68. * @param filePath String of the full path to the specified file.
  69. * @param pageIndexs The page number range.
  70. */
  71. - (void)convertToFilePath:(NSString *)filePath pageIndexs:(NSArray *)pageIndexs options:(CPDFConvertOptions *)options;
  72. /**
  73. * Cancels the conversion task.
  74. */
  75. - (void)cancel;
  76. @end