123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- import 'dart:convert';
- import 'package:compdfkit_flutter/configuration/attributes/cpdf_annot_attr.dart';
- import 'cpdf_options.dart';
- class CPDFConfiguration {
- CPDFModeConfig modeConfig;
- CPDFToolbarConfig toolbarConfig;
- CPDFReaderViewConfig readerViewConfig;
- CPDFAnnotationsConfig annotationsConfig;
- CPDFContentEditorConfig contentEditorConfig;
- CPDFFormsConfig formsConfig;
- CPDFGlobalConfig globalConfig;
- CPDFConfiguration(
- {this.modeConfig =
- const CPDFModeConfig(initialViewMode: CPDFViewMode.viewer),
- this.toolbarConfig = const CPDFToolbarConfig(),
- this.readerViewConfig = const CPDFReaderViewConfig(),
- this.annotationsConfig = const CPDFAnnotationsConfig(),
- this.contentEditorConfig = const CPDFContentEditorConfig(),
- this.formsConfig = const CPDFFormsConfig(),
- this.globalConfig = const CPDFGlobalConfig()});
- String toJson() => jsonEncode({
- 'modeConfig': modeConfig.toJson(),
- 'toolbarConfig': toolbarConfig.toJson(),
- 'readerViewConfig': readerViewConfig.toJson(),
- 'annotationsConfig': annotationsConfig.toJson(),
- 'contentEditorConfig': contentEditorConfig.toJson(),
- 'formsConfig': formsConfig.toJson(),
- 'global': globalConfig.toJson()
- });
- }
- class CPDFModeConfig {
-
- final CPDFViewMode initialViewMode;
-
- final List<CPDFViewMode> availableViewModes;
-
-
-
- final bool readerOnly;
- const CPDFModeConfig(
- {this.initialViewMode = CPDFViewMode.viewer,
- this.readerOnly = false,
- this.availableViewModes = CPDFViewMode.values});
- Map<String, dynamic> toJson() => {
- 'initialViewMode': initialViewMode.name,
- 'readerOnly': readerOnly,
- 'availableViewModes': availableViewModes.map((e) => e.name).toList()
- };
- }
- class CPDFToolbarConfig {
-
-
-
-
-
- final List<CPDFToolbarAction> androidAvailableActions;
-
-
-
- final List<CPDFToolbarAction> iosLeftBarAvailableActions;
-
-
-
- final List<CPDFToolbarAction> iosRightBarAvailableActions;
-
- final List<CPDFToolbarMenuAction> availableMenus;
- final bool mainToolbarVisible;
- const CPDFToolbarConfig(
- {this.androidAvailableActions = const [
- CPDFToolbarAction.thumbnail,
- CPDFToolbarAction.search,
- CPDFToolbarAction.bota,
- CPDFToolbarAction.menu,
- ],
- this.iosLeftBarAvailableActions = const [
- CPDFToolbarAction.back,
- CPDFToolbarAction.thumbnail,
- ],
- this.iosRightBarAvailableActions = const [
- CPDFToolbarAction.search,
- CPDFToolbarAction.bota,
- CPDFToolbarAction.menu
- ],
- this.availableMenus = const [
- CPDFToolbarMenuAction.viewSettings,
- CPDFToolbarMenuAction.documentEditor,
- CPDFToolbarMenuAction.security,
- CPDFToolbarMenuAction.watermark,
- CPDFToolbarMenuAction.flattened,
- CPDFToolbarMenuAction.documentInfo,
- CPDFToolbarMenuAction.save,
- CPDFToolbarMenuAction.share,
- CPDFToolbarMenuAction.openDocument,
- CPDFToolbarMenuAction.snip
- ],
- this.mainToolbarVisible = true});
- Map<String, dynamic> toJson() => {
- 'androidAvailableActions':
- androidAvailableActions.map((e) => e.name).toList(),
- 'iosLeftBarAvailableActions':
- iosLeftBarAvailableActions.map((e) => e.name).toList(),
- 'iosRightBarAvailableActions':
- iosRightBarAvailableActions.map((e) => e.name).toList(),
- 'availableMenus': availableMenus.map((e) => e.name).toList(),
- 'mainToolbarVisible' : mainToolbarVisible
- };
- }
- class CPDFReaderViewConfig {
-
- final bool linkHighlight;
-
- final bool formFieldHighlight;
-
-
- final CPDFDisplayMode displayMode;
-
- final bool continueMode;
-
-
-
-
-
- final bool verticalMode;
-
-
-
-
- final bool cropMode;
-
-
-
- final CPDFThemes themes;
-
- final bool enableSliderBar;
-
- final bool enablePageIndicator;
-
- final int pageSpacing;
-
- final double pageScale;
-
- final bool pageSameWidth;
- final List<int> margins;
- const CPDFReaderViewConfig(
- {this.linkHighlight = true,
- this.formFieldHighlight = true,
- this.displayMode = CPDFDisplayMode.singlePage,
- this.continueMode = true,
- this.verticalMode = true,
- this.cropMode = false,
- this.themes = CPDFThemes.light,
- this.enableSliderBar = true,
- this.enablePageIndicator = true,
- this.pageSpacing = 10,
- this.pageScale = 1.0,
- this.pageSameWidth = true,
- this.margins = const [0,0,0,0]});
- Map<String, dynamic> toJson() => {
- 'linkHighlight': linkHighlight,
- 'formFieldHighlight': formFieldHighlight,
- 'displayMode': displayMode.name,
- 'continueMode': continueMode,
- 'verticalMode': verticalMode,
- 'cropMode': cropMode,
- 'themes': themes.name,
- 'enableSliderBar': enableSliderBar,
- 'enablePageIndicator': enablePageIndicator,
- 'pageSpacing': pageSpacing,
- 'pageScale': pageScale,
- 'pageSameWidth': pageSameWidth,
- 'margins' : margins
- };
- }
- class CPDFAnnotationsConfig {
-
-
- final String annotationAuthor;
-
-
- final List<CPDFAnnotationType> availableTypes;
-
-
- final List<CPDFConfigTool> availableTools;
-
- final CPDFAnnotAttribute initAttribute;
- const CPDFAnnotationsConfig(
- {this.availableTypes = CPDFAnnotationType.values,
- this.availableTools = CPDFConfigTool.values,
- this.initAttribute = const CPDFAnnotAttribute(),
- this.annotationAuthor = ""});
- Map<String, dynamic> toJson() => {
- 'availableTypes': availableTypes.map((e) => e.name).toList(),
- 'availableTools': availableTools.map((e) => e.name).toList(),
- 'initAttribute': initAttribute.toJson(),
- 'annotationAuthor': annotationAuthor
- };
- }
- class CPDFAnnotAttribute {
-
- final CPDFTextAttr noteAttr;
- final CPDFHighlightAttr highlightAttr;
- final CPDFUnderlineAttr underlineAttr;
- final CPDFSquigglyAttr squigglyAttr;
- final CPDFStrikeoutAttr strikeoutAttr;
- final CPDFInkAttr inkAttr;
- final CPDFSquareAttr squareAttr;
- final CPDFCircleAttr circleAttr;
- final CPDFLineAttr lineAttr;
- final CPDFArrowAttr arrowAttr;
- final CPDFFreetextAttr freeTextAttr;
- const CPDFAnnotAttribute({
- this.noteAttr = const CPDFTextAttr(),
- this.highlightAttr = const CPDFHighlightAttr(),
- this.underlineAttr = const CPDFUnderlineAttr(),
- this.squigglyAttr = const CPDFSquigglyAttr(),
- this.strikeoutAttr = const CPDFStrikeoutAttr(),
- this.inkAttr = const CPDFInkAttr(),
- this.squareAttr = const CPDFSquareAttr(),
- this.circleAttr = const CPDFCircleAttr(),
- this.lineAttr = const CPDFLineAttr(),
- this.arrowAttr = const CPDFArrowAttr(),
- this.freeTextAttr = const CPDFFreetextAttr(),
- });
- Map<String, dynamic> toJson() => {
- 'note': noteAttr.toJson(),
- 'highlight': highlightAttr.toJson(),
- 'underline': underlineAttr.toJson(),
- 'squiggly': squigglyAttr.toJson(),
- 'strikeout': strikeoutAttr.toJson(),
- 'ink': inkAttr.toJson(),
- 'square': squareAttr.toJson(),
- 'circle': circleAttr.toJson(),
- 'line': lineAttr.toJson(),
- 'arrow': arrowAttr.toJson(),
- 'freeText': freeTextAttr.toJson()
- };
- }
- class CPDFContentEditorConfig {
-
-
- final List<CPDFContentEditorType> availableTypes;
-
- final List<CPDFConfigTool> availableTools;
- final CPDFContentEditorAttribute initAttribute;
- const CPDFContentEditorConfig(
- {this.availableTypes = CPDFContentEditorType.values,
- this.availableTools = CPDFConfigTool.values,
- this.initAttribute = const CPDFContentEditorAttribute()});
- Map<String, dynamic> toJson() => {
- 'availableTypes': availableTypes.map((e) => e.name).toList(),
- 'availableTools': availableTools.map((e) => e.name).toList(),
- 'initAttribute': initAttribute.toJson()
- };
- }
- class CPDFContentEditorAttribute {
- final CPDFEditorTextAttr text;
- const CPDFContentEditorAttribute({this.text = const CPDFEditorTextAttr()});
- Map<String, dynamic> toJson() => {'text': text.toJson()};
- }
- class CPDFFormsConfig {
-
- final List<CPDFFormType> availableTypes;
-
- final List<CPDFConfigTool> availableTools;
-
- final CPDFFormAttribute initAttribute;
- const CPDFFormsConfig(
- {this.availableTypes = CPDFFormType.values,
- this.availableTools = const [CPDFConfigTool.undo, CPDFConfigTool.redo],
- this.initAttribute = const CPDFFormAttribute()});
- Map<String, dynamic> toJson() => {
- 'availableTypes': availableTypes.map((e) => e.name).toList(),
- 'availableTools': availableTools.map((e) => e.name).toList(),
- 'initAttribute': initAttribute.toJson()
- };
- }
- class CPDFFormAttribute {
- final CPDFTextFieldAttr textFieldAttr;
- final CPDFCheckBoxAttr checkBoxAttr;
- final CPDFRadioButtonAttr radioButtonAttr;
- final CPDFListBoxAttr listBoxAttr;
- final CPDFComboBoxAttr comboBoxAttr;
- final CPDFPushButtonAttr pushButtonAttr;
- final CPDFSignatureWidgetAttr signaturesFieldsAttr;
- const CPDFFormAttribute({
- this.textFieldAttr = const CPDFTextFieldAttr(),
- this.checkBoxAttr = const CPDFCheckBoxAttr(),
- this.radioButtonAttr = const CPDFRadioButtonAttr(),
- this.listBoxAttr = const CPDFListBoxAttr(),
- this.comboBoxAttr = const CPDFComboBoxAttr(),
- this.pushButtonAttr = const CPDFPushButtonAttr(),
- this.signaturesFieldsAttr = const CPDFSignatureWidgetAttr(),
- });
- Map<String, dynamic> toJson() => {
- 'textField': textFieldAttr.toJson(),
- 'checkBox': checkBoxAttr.toJson(),
- 'radioButton': radioButtonAttr.toJson(),
- 'listBox': listBoxAttr.toJson(),
- 'comboBox': comboBoxAttr.toJson(),
- 'pushButton': pushButtonAttr.toJson(),
- 'signaturesFields': signaturesFieldsAttr.toJson()
- };
- }
- class CPDFGlobalConfig {
-
-
- final CPDFThemeMode themeMode;
-
-
- final bool fileSaveExtraFontSubset;
- const CPDFGlobalConfig(
- {this.themeMode = CPDFThemeMode.system,
- this.fileSaveExtraFontSubset = true});
- Map<String, dynamic> toJson() => {
- "themeMode": themeMode.name,
- "fileSaveExtraFontSubset": fileSaveExtraFontSubset
- };
- }
|