cpdf_options.dart 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. /// [CPDFEdgeInsets] defines the padding for a PDF document.
  110. ///
  111. /// - On **Android**, you can set individual margins for [top], [bottom], [left], and [right].
  112. /// To adjust the spacing between pages, use the `setPageSpacing()` method.
  113. ///
  114. /// - On **iOS**, you can also configure [top], [bottom], [left], and [right] margins.
  115. /// The spacing between pages is equal to the [top] margin.
  116. class CPDFEdgeInsets {
  117. final int left;
  118. final int top;
  119. final int right;
  120. final int bottom;
  121. const CPDFEdgeInsets.all(int value)
  122. : left = value,
  123. top = value,
  124. right = value,
  125. bottom = value;
  126. const CPDFEdgeInsets.symmetric(
  127. {required int horizontal, required int vertical})
  128. : left = horizontal,
  129. top = vertical,
  130. right = horizontal,
  131. bottom = vertical;
  132. const CPDFEdgeInsets.only(
  133. {required this.left,
  134. required this.top,
  135. required this.right,
  136. required this.bottom});
  137. Map<String, dynamic> toJson() => {
  138. 'left': left,
  139. 'top': top,
  140. 'right': right,
  141. 'bottom': bottom,
  142. };
  143. }
  144. enum CPDFDocumentPermissions {
  145. none,
  146. user,
  147. owner
  148. }
  149. /// Error types of the opening document.
  150. enum CPDFDocumentError {
  151. /// No read permission.
  152. noReadPermission,
  153. /// SDK No verified license
  154. notVerifyLicense,
  155. /// open document success.
  156. success,
  157. /// Unknown error
  158. unknown,
  159. /// File not found or could not be opened.
  160. errorFile,
  161. /// File not in PDF format or corrupted.
  162. errorFormat,
  163. /// Password required or incorrect password.
  164. errorPassword,
  165. /// Unsupported security scheme.
  166. errorSecurity,
  167. /// Error page.
  168. errorPage
  169. }