cpdf_options.dart 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. // Copyright © 2014-2025 PDF Technologies, Inc. All Rights Reserved.
  2. //
  3. // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  4. // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  5. // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  6. // This notice may not be removed from this file.
  7. import 'dart:ui';
  8. import 'package:compdfkit_flutter/util/extension/cpdf_color_extension.dart';
  9. enum CPDFViewMode { viewer, annotations, contentEditor, forms, signatures }
  10. /// The [CPDFToolbarAction.back] button will only be displayed on the leftmost side of the top toolbar on the Android platform
  11. enum CPDFToolbarAction { back, thumbnail, search, bota, menu }
  12. enum CPDFToolbarMenuAction {
  13. viewSettings,
  14. documentEditor,
  15. security,
  16. watermark,
  17. flattened,
  18. documentInfo,
  19. save,
  20. share,
  21. openDocument,
  22. /// The PDF capture function allows you to capture an area
  23. /// in the PDF document and convert it into an image.
  24. snip
  25. }
  26. enum CPDFDisplayMode { singlePage, doublePage, coverPage }
  27. /// readerView background themes
  28. enum CPDFThemes {
  29. /// Bright mode, readerview background is white
  30. light('#FFFFFFFF'),
  31. /// dark mode, readerview background is black
  32. dark('#FF000000'),
  33. /// brown paper color
  34. sepia('#FFFFEFBE'),
  35. /// Light green, eye protection mode
  36. reseda('#FFCDE6D0');
  37. final String color;
  38. const CPDFThemes(this.color);
  39. // 根据 Color 对象获取对应的 CPDFThemes
  40. static CPDFThemes of(Color color) {
  41. return CPDFThemes.values.firstWhere(
  42. (theme) => theme.color == color.toHex().toUpperCase(),
  43. orElse: () => CPDFThemes.light,
  44. );
  45. }
  46. // 获取颜色值
  47. String getColor() {
  48. return color;
  49. }
  50. }
  51. enum CPDFAnnotationType {
  52. note,
  53. highlight,
  54. underline,
  55. squiggly,
  56. strikeout,
  57. ink,
  58. // only ios platform
  59. pencil,
  60. circle,
  61. square,
  62. arrow,
  63. line,
  64. freetext,
  65. signature,
  66. stamp,
  67. pictures,
  68. link,
  69. sound
  70. }
  71. enum CPDFConfigTool { setting, undo, redo }
  72. enum CPDFAnnotBorderStyle { solid, dashed }
  73. enum CPDFLineType { none, openArrow, closedArrow, square, circle, diamond }
  74. enum CPDFAlignment { left, center, right }
  75. enum CPDFTypeface { courier, helvetica, timesRoman }
  76. extension CPDFTypefaceExtension on CPDFTypeface {
  77. String getFontName() {
  78. switch (name) {
  79. case 'courier':
  80. return 'Courier';
  81. case 'helvetica':
  82. return 'Helvetica';
  83. case 'timesRoman':
  84. return 'Times-Roman';
  85. default:
  86. return 'Courier';
  87. }
  88. }
  89. }
  90. extension CPDFTypefaceEnumExten on Iterable<CPDFTypeface> {
  91. CPDFTypeface byFontName(String fontName) {
  92. switch (fontName.toLowerCase()) {
  93. case 'courier':
  94. return CPDFTypeface.courier;
  95. case 'helvetica':
  96. return CPDFTypeface.helvetica;
  97. case 'times-roman':
  98. return CPDFTypeface.timesRoman;
  99. default:
  100. return CPDFTypeface.courier;
  101. }
  102. }
  103. }
  104. enum CPDFContentEditorType { editorText, editorImage }
  105. enum CPDFFormType {
  106. textField,
  107. checkBox,
  108. radioButton,
  109. listBox,
  110. comboBox,
  111. signaturesFields,
  112. pushButton
  113. }
  114. enum CPDFCheckStyle { check, circle, cross, diamond, square, star }
  115. enum CPDFThemeMode { light, dark, system }
  116. /// [CPDFEdgeInsets] defines the padding for a PDF document.
  117. ///
  118. /// - On **Android**, you can set individual margins for [top], [bottom], [left], and [right].
  119. /// To adjust the spacing between pages, use the `setPageSpacing()` method.
  120. ///
  121. /// - On **iOS**, you can also configure [top], [bottom], [left], and [right] margins.
  122. /// The spacing between pages is equal to the [top] margin.
  123. class CPDFEdgeInsets {
  124. final int left;
  125. final int top;
  126. final int right;
  127. final int bottom;
  128. const CPDFEdgeInsets.all(int value)
  129. : left = value,
  130. top = value,
  131. right = value,
  132. bottom = value;
  133. const CPDFEdgeInsets.symmetric(
  134. {required int horizontal, required int vertical})
  135. : left = horizontal,
  136. top = vertical,
  137. right = horizontal,
  138. bottom = vertical;
  139. const CPDFEdgeInsets.only(
  140. {required this.left,
  141. required this.top,
  142. required this.right,
  143. required this.bottom});
  144. Map<String, dynamic> toJson() => {
  145. 'left': left,
  146. 'top': top,
  147. 'right': right,
  148. 'bottom': bottom,
  149. };
  150. }
  151. enum CPDFDocumentPermissions {
  152. none,
  153. user,
  154. owner
  155. }
  156. /// Error types of the opening document.
  157. enum CPDFDocumentError {
  158. /// No read permission.
  159. noReadPermission,
  160. /// SDK No verified license
  161. notVerifyLicense,
  162. /// open document success.
  163. success,
  164. /// Unknown error
  165. unknown,
  166. /// File not found or could not be opened.
  167. errorFile,
  168. /// File not in PDF format or corrupted.
  169. errorFormat,
  170. /// Password required or incorrect password.
  171. errorPassword,
  172. /// Unsupported security scheme.
  173. errorSecurity,
  174. /// Error page.
  175. errorPage
  176. }
  177. enum CPDFDocumentEncryptAlgo {
  178. // RC4 encryption algorithm.
  179. rc4,
  180. /// AES encryption with a 128-bit key.
  181. aes128,
  182. /// AES encryption with a 256-bit key.
  183. aes256,
  184. /// No encryption algorithm selected.
  185. noEncryptAlgo;
  186. }
  187. enum CPDFWatermarkType {
  188. text,
  189. image
  190. }