cpdf_options.dart 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. // Copyright © 2014-2024 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('#FFFFFF'),
  31. /// dark mode, readerview background is black
  32. dark('#000000'),
  33. /// brown paper color
  34. sepia('#FFEFBE'),
  35. /// Light green, eye protection mode
  36. reseda('#CDE6D0');
  37. final String color;
  38. const CPDFThemes(this.color);
  39. // 获取颜色值
  40. String getColor() {
  41. return color;
  42. }
  43. }
  44. enum CPDFAnnotationType {
  45. note,
  46. highlight,
  47. underline,
  48. squiggly,
  49. strikeout,
  50. ink,
  51. // only ios platform
  52. pencil,
  53. circle,
  54. square,
  55. arrow,
  56. line,
  57. freetext,
  58. signature,
  59. stamp,
  60. pictures,
  61. link,
  62. sound
  63. }
  64. enum CPDFConfigTool { setting, undo, redo }
  65. enum CPDFAnnotBorderStyle { solid, dashed }
  66. enum CPDFLineType { none, openArrow, closedArrow, square, circle, diamond }
  67. enum CPDFAlignment { left, center, right }
  68. enum CPDFTypeface { courier, helvetica, timesRoman }
  69. extension CPDFTypefaceExtension on CPDFTypeface {
  70. String getFontName() {
  71. switch (name) {
  72. case 'courier':
  73. return 'Courier';
  74. case 'helvetica':
  75. return 'Helvetica';
  76. case 'timesRoman':
  77. return 'Times-Roman';
  78. default:
  79. return 'Courier';
  80. }
  81. }
  82. }
  83. extension CPDFTypefaceEnumExten on Iterable<CPDFTypeface> {
  84. CPDFTypeface byFontName(String fontName) {
  85. switch (fontName.toLowerCase()) {
  86. case 'courier':
  87. return CPDFTypeface.courier;
  88. case 'helvetica':
  89. return CPDFTypeface.helvetica;
  90. case 'times-roman':
  91. return CPDFTypeface.timesRoman;
  92. default:
  93. return CPDFTypeface.courier;
  94. }
  95. }
  96. }
  97. enum CPDFContentEditorType { editorText, editorImage }
  98. enum CPDFFormType {
  99. textField,
  100. checkBox,
  101. radioButton,
  102. listBox,
  103. comboBox,
  104. signaturesFields,
  105. pushButton
  106. }
  107. enum CPDFCheckStyle { check, circle, cross, diamond, square, star }
  108. enum CPDFThemeMode { light, dark, system }
  109. /// The [CPDFEdgeInsets] is used to set the padding of the PDF document.
  110. ///
  111. /// [Android] can only set horizontal margins, [top] and [bottom] margins.
  112. /// Horizontal spacing cannot be set independently.
  113. /// The horizontal spacing value is set using the [left] attribute,
  114. /// the spacing between two pages is the same as the top spacing.
  115. ///
  116. /// The [iOS] platform can set the [top], [bottom], [left] and [right] margins,
  117. /// and the spacing between two pages is the same as the top spacing.
  118. class CPDFEdgeInsets {
  119. final int left;
  120. final int top;
  121. final int right;
  122. final int bottom;
  123. const CPDFEdgeInsets.all(int value)
  124. : left = value,
  125. top = value,
  126. right = value,
  127. bottom = value;
  128. const CPDFEdgeInsets.symmetric(
  129. {required int horizontal, required int vertical})
  130. : left = horizontal,
  131. top = vertical,
  132. right = horizontal,
  133. bottom = vertical;
  134. const CPDFEdgeInsets.only(
  135. {required this.left,
  136. required this.top,
  137. required this.right,
  138. required this.bottom});
  139. Map<String, dynamic> toJson() => {
  140. 'left': left,
  141. 'top': top,
  142. 'right': right,
  143. 'bottom': bottom,
  144. };
  145. }
  146. enum CPDFDocumentPermissions {
  147. none,
  148. user,
  149. owner
  150. }
  151. /// Error types of the opening document.
  152. enum CPDFDocumentError {
  153. /// No read permission.
  154. noReadPermission,
  155. /// SDK No verified license
  156. notVerifyLicense,
  157. /// open document success.
  158. success,
  159. /// Unknown error
  160. unknown,
  161. /// File not found or could not be opened.
  162. errorFile,
  163. /// File not in PDF format or corrupted.
  164. errorFormat,
  165. /// Password required or incorrect password.
  166. errorPassword,
  167. /// Unsupported security scheme.
  168. errorSecurity,
  169. /// Error page.
  170. errorPage
  171. }