CPDFWatermark.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. //
  2. // CPDFWatermark.h
  3. // ComPDFKit
  4. //
  5. // Copyright © 2014-2022 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 <ComPDFKit/CPDFKitPlatform.h>
  13. typedef NS_ENUM(NSInteger, CPDFWatermarkType) {
  14. CPDFWatermarkTypeText = 0,
  15. CPDFWatermarkTypeImage
  16. };
  17. typedef NS_ENUM(NSInteger, CPDFWatermarkVerticalPosition) {
  18. CPDFWatermarkVerticalPositionTop = 0,
  19. CPDFWatermarkVerticalPositionCenter,
  20. CPDFWatermarkVerticalPositionBottom
  21. };
  22. typedef NS_ENUM(NSInteger, CPDFWatermarkHorizontalPosition) {
  23. CPDFWatermarkHorizontalPositionLeft = 0,
  24. CPDFWatermarkHorizontalPositionCenter,
  25. CPDFWatermarkHorizontalPositionRight
  26. };
  27. @class CPDFDocument;
  28. /**
  29. * Add and delete image and text watermarks.
  30. */
  31. @interface CPDFWatermark : NSObject
  32. #pragma mark - Initializers
  33. /**
  34. * Initializes the watermark.
  35. *
  36. * @param document The document with which the watermark is associated.
  37. * @param type The type index of the watermark.
  38. * @see CPDFWatermarkType
  39. */
  40. - (instancetype)initWithDocument:(CPDFDocument *)document type:(CPDFWatermarkType)type;
  41. #pragma mark - Accessors
  42. /**
  43. * Returns the type for the watermark.
  44. *
  45. * @see CPDFWatermarkType
  46. */
  47. @property (nonatomic,readonly) CPDFWatermarkType type;
  48. /**
  49. * Method to get / set the text for the watermark (image watermark does not work).
  50. */
  51. @property (nonatomic,copy) NSString *text;
  52. /**
  53. * Method to get / set the text font for the watermark (image watermark does not work).
  54. *
  55. * @discussion The text font for the watermark; may return NULL if the watermark was created with image.
  56. * Default Font : Helvetica 24
  57. */
  58. @property (nonatomic,retain) CPDFKitPlatformFont *textFont;
  59. /**
  60. * Method to get / set the text color for the watermark (image watermark does not work).
  61. */
  62. @property (nonatomic,retain) CPDFKitPlatformColor *textColor;
  63. /**
  64. * Method to get / set the image for the watermark (text watermark does not work).
  65. */
  66. @property (nonatomic,retain) CPDFKitPlatformImage *image;
  67. /**
  68. * Method to get / set the scale factor for the watermark.
  69. *
  70. * @discussion Default is 1.0.
  71. */
  72. @property (nonatomic,assign) CGFloat scale;
  73. /**
  74. * Method to get / set the rotation for the watermark.
  75. *
  76. * @discussion Range : 0~360, Default is 0.0.
  77. */
  78. @property (nonatomic,assign) CGFloat rotation;
  79. /**
  80. * Method to get / set the opacity for the watermark.
  81. *
  82. * @discussion Range : 0~1, Default is 1.0.
  83. */
  84. @property (nonatomic,assign) CGFloat opacity;
  85. /**
  86. * Method to get / set the page range for the watermark.
  87. *
  88. * @discussion If not set, default to all pages.
  89. */
  90. @property (nonatomic,assign) NSRange pageRange;
  91. /**
  92. * Method to get / set the page range for the watermark by string.
  93. *
  94. * @discussion A page range string, Such as "0,3,5-7".
  95. */
  96. @property (nonatomic,retain) NSString *pageString;
  97. /**
  98. * Method to get / set the vertical position for the watermark.
  99. *
  100. * @discussion Default is CPDFWatermarkVerticalPositionCenter.
  101. * @see CPDFWatermarkVerticalPosition
  102. */
  103. @property (nonatomic,assign) CPDFWatermarkVerticalPosition verticalPosition;
  104. /**
  105. * Method to get / set the horizontal position for the watermark.
  106. *
  107. * @discussion Default is CPDFWatermarkHorizontalPositionCenter.
  108. * @see CPDFWatermarkHorizontalPosition
  109. */
  110. @property (nonatomic,assign) CPDFWatermarkHorizontalPosition horizontalPosition;
  111. /**
  112. * Method to get / set the horizontal translation for the watermark.
  113. *
  114. * @discussion The translation relative to the horizontal position.
  115. */
  116. @property (nonatomic,assign) CGFloat tx;
  117. /**
  118. * Method to get / set the vertical translation for the watermark.
  119. *
  120. * @discussion The translation relative to the vertical position.
  121. */
  122. @property (nonatomic,assign) CGFloat ty;
  123. /**
  124. * Method to get/set watermark to locate in front of the content.
  125. */
  126. @property (nonatomic,assign) BOOL isFront;
  127. /**
  128. * Method to get / set tiled watermark for the page(image watermark does not work).
  129. */
  130. @property (nonatomic,assign) BOOL isTilePage;
  131. /**
  132. * Method to get / set the vertical spacing for the tiled watermark.
  133. */
  134. @property (nonatomic,assign) CGFloat verticalSpacing;
  135. /**
  136. * Method to get / set the horizontal spacing for the tiled watermark.
  137. */
  138. @property (nonatomic,assign) CGFloat horizontalSpacing;
  139. @end