|
@@ -0,0 +1,419 @@
|
|
|
+import { BorderWidth, ColorAlpha, CPDFAlignment, CPDFAnnotationType, CPDFBorderStyle, CPDFCheckStyle, CPDFConfigTool, CPDFContentEditorType, CPDFDisplayMode, CPDFFormType, CPDFLineType, CPDFThemes, CPDFToolbarAction, CPDFToolbarMenuAction, CPDFTypeface, CPDFViewMode, DashGap, FontSize, HexColor } from "./CPDFOptions";
|
|
|
+
|
|
|
+/**
|
|
|
+ * Configuration information for displaying PDF using the ComPDFKit.openDocument method.
|
|
|
+ * Used to configure UI elements, PDF properties, etc.
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * const configuration : CPDFConfiguration = {
|
|
|
+ * modeConfig: {
|
|
|
+ * initialViewMode: CPDFModeConfig.ViewMode.VIEWER,
|
|
|
+ * availableViewModes: [
|
|
|
+ * CPDFModeConfig.ViewMode.VIEWER,
|
|
|
+ * CPDFModeConfig.ViewMode.ANNOTATIONS,
|
|
|
+ * CPDFModeConfig.ViewMode.CONTENT_EDITOR,
|
|
|
+ * CPDFModeConfig.ViewMode.FORMS,
|
|
|
+ * CPDFModeConfig.ViewMode.SIGNATURES
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * ComPDFKit.openDocument(document, 'password', JSON.stringify(configuration))
|
|
|
+ */
|
|
|
+export class CPDFConfiguration {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * PDF mode configuration
|
|
|
+ */
|
|
|
+ modeConfig?: {
|
|
|
+ /**
|
|
|
+ * Default mode to display when opening the PDF View, default is [CPDFToolbarAction.VIEWER]
|
|
|
+ */
|
|
|
+ initialViewMode?: CPDFViewMode,
|
|
|
+ /**
|
|
|
+ * Configure supported modes
|
|
|
+ */
|
|
|
+ availableViewModes?: CPDFViewMode[]
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Configuration for top toolbar functionality
|
|
|
+ */
|
|
|
+ toolbarConfig?: {
|
|
|
+ /**
|
|
|
+ * Top toolbar actions for Android platform
|
|
|
+ *
|
|
|
+ * Default: thumbnail, search, bota, menu.
|
|
|
+ *
|
|
|
+ * {@link CPDFToolbarAction.BACK} button will be shown only on the far left
|
|
|
+ */
|
|
|
+ androidAvailableActions?: CPDFToolbarAction[],
|
|
|
+ /**
|
|
|
+ * Left toolbar actions for iOS platform
|
|
|
+ *
|
|
|
+ * Default: back, thumbnail
|
|
|
+ */
|
|
|
+ iosLeftBarAvailableActions?: CPDFToolbarAction[],
|
|
|
+ /**
|
|
|
+ * Right toolbar actions for iOS platform
|
|
|
+ *
|
|
|
+ * Default: search, bota, menu
|
|
|
+ */
|
|
|
+ iosRightBarAvailableActions?: CPDFToolbarAction[],
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Configure the menu options opened in the top toolbar {@link CPDFToolbarAction.MENU}
|
|
|
+ */
|
|
|
+ availableMenus?: CPDFToolbarMenuAction[]
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * annotation config
|
|
|
+ */
|
|
|
+ annotationsConfig?: {
|
|
|
+ /**
|
|
|
+ * {@link CPDFViewMode.ANNOTATIONS} mode, list of annotation functions shown at the bottom of the view.
|
|
|
+ */
|
|
|
+ availableType?: CPDFAnnotationType[],
|
|
|
+ /**
|
|
|
+ * {@link CPDFViewMode.ANNOTATIONS} mode, annotation tools shown at the bottom of the view.
|
|
|
+ */
|
|
|
+ availableTools?: CPDFConfigTool[],
|
|
|
+ /**
|
|
|
+ * When adding an annotation, the annotation’s default attributes.
|
|
|
+ */
|
|
|
+ initAttribute?: {
|
|
|
+ /**
|
|
|
+ * Note annotation attribute configuration.
|
|
|
+ * @param { HexColor } [color] HEX color: #1460F3
|
|
|
+ * @param { ColorAlpha } [alpha] Color opacity, value range: 0~255
|
|
|
+ */
|
|
|
+ note?: {
|
|
|
+ color?: HexColor,
|
|
|
+ alpha?: ColorAlpha
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Highlight annotation attribute configuration.
|
|
|
+ * @param { HexColor } [color] HEX color: #1460F3.
|
|
|
+ * @param { ColorAlpha } [alpha] Color opacity, value range: 0~255.
|
|
|
+ */
|
|
|
+ highlight?: {
|
|
|
+ color?: HexColor,
|
|
|
+ alpha?: ColorAlpha
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Underline annotation attribute configuration.
|
|
|
+ * @param { HexColor } [color] HEX color: #1460F3
|
|
|
+ * @param { number } [alpha] Color opacity, value range: 0~255
|
|
|
+ */
|
|
|
+ underline?: {
|
|
|
+ color?: HexColor,
|
|
|
+ alpha?: ColorAlpha
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Squiggly annotation attribute configuration.
|
|
|
+ * @param { HexColor } [color] HEX color: #1460F3
|
|
|
+ * @param { ColorAlpha } [alpha] Color opacity, value range: 0~255
|
|
|
+ */
|
|
|
+ squiggly?: {
|
|
|
+ color?: HexColor,
|
|
|
+ alpha?: ColorAlpha
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Strikeout annotation attribute configuration.
|
|
|
+ * @param { HexColor } [color] HEX color: #1460F3
|
|
|
+ * @param { ColorAlpha } [alpha] Color opacity, value range: 0~255
|
|
|
+ */
|
|
|
+ strikeout?: {
|
|
|
+ color?: HexColor,
|
|
|
+ alpha?: ColorAlpha
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Ink annotation attribute configuration.
|
|
|
+ * @param {HexColor} [color] HEX color: #1460F3
|
|
|
+ * @param {ColorAlpha} [alpha] Color opacity, value range: 0~255
|
|
|
+ * @param { BorderWidth } [borderWidth] Brush thickness, value range: 1~10
|
|
|
+ */
|
|
|
+ ink?: {
|
|
|
+ color?: HexColor,
|
|
|
+ alpha?: ColorAlpha,
|
|
|
+ borderWidth?: BorderWidth
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * square annotation attribute configuration.
|
|
|
+ * @param { HexColor } [fillColor] HEX color: #1460F3
|
|
|
+ * @param { HexColor } [borderColor] HEX color: #1460F3
|
|
|
+ * @param { ColorAlpha } [colorAlpha] fill color and border color opacity. value range:0~255
|
|
|
+ * @param { BorderWidth } [borderWidth] border thickness, value range:1~10
|
|
|
+ * @param { object } [borderStyle] Set the border style to dashed or solid.
|
|
|
+ */
|
|
|
+ square?: {
|
|
|
+ fillColor?: HexColor,
|
|
|
+ borderColor?: HexColor,
|
|
|
+ colorAlpha?: ColorAlpha,
|
|
|
+ borderWidth?: BorderWidth,
|
|
|
+ borderStyle?: {
|
|
|
+ /**
|
|
|
+ * default: {@link CPDFBorderStyle.SOLID}
|
|
|
+ */
|
|
|
+ style?: CPDFBorderStyle,
|
|
|
+ /**
|
|
|
+ * Dashed gap, only style={@link CPDFBorderStyle.DASHED} is valid.
|
|
|
+ */
|
|
|
+ dashGap?: DashGap
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Circle annotation attribute configuration.
|
|
|
+ * @param { HexColor } [fillColor] HEX color: #1460F3
|
|
|
+ * @param { HexColor } [borderColor] HEX color: #1460F3
|
|
|
+ * @param { ColorAlpha } [colorAlpha] fill color and border color opacity. value range:0~255
|
|
|
+ * @param { BorderWidth } [borderWidth] border thickness, value range:1~10
|
|
|
+ * @param { object } [borderStyle] Set the border style to dashed or solid.
|
|
|
+ */
|
|
|
+ circle?: {
|
|
|
+ fillColor?: HexColor,
|
|
|
+ borderColor?: HexColor,
|
|
|
+ colorAlpha?: ColorAlpha,
|
|
|
+ borderWidth?: BorderWidth,
|
|
|
+ borderStyle?: {
|
|
|
+ /**
|
|
|
+ * default: {@link CPDFBorderStyle.SOLID}
|
|
|
+ */
|
|
|
+ style?: CPDFBorderStyle,
|
|
|
+ /**
|
|
|
+ * Dashed gap, only style={@link CPDFBorderStyle.DASHED} is valid.
|
|
|
+ */
|
|
|
+ dashGap?: DashGap
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Line annotation attribute configuration.
|
|
|
+ * @param { HexColor } [borderColor] HEX color: #1460F3
|
|
|
+ * @param { ColorAlpha } [borderAlpha] line color opacity. value range:0~255
|
|
|
+ * @param { BorderWidth } [borderWidth] border thickness, value range:1~10
|
|
|
+ * @param { object } [borderStyle] Set the border style to dashed or solid.
|
|
|
+ */
|
|
|
+ line?: {
|
|
|
+ borderColor?: HexColor,
|
|
|
+ borderAlpha?: ColorAlpha,
|
|
|
+ borderWidth?: BorderWidth,
|
|
|
+ borderStyle?: {
|
|
|
+ /**
|
|
|
+ * default: {@link CPDFBorderStyle.SOLID}
|
|
|
+ */
|
|
|
+ style?: CPDFBorderStyle,
|
|
|
+ /**
|
|
|
+ * Dashed gap, only style={@link CPDFBorderStyle.DASHED} is valid.
|
|
|
+ */
|
|
|
+ dashGap?: DashGap
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Arrow annotation attribute configuration.
|
|
|
+ * @param { HexColor } [borderColor] HEX color: #1460F3
|
|
|
+ * @param { ColorAlpha } [borderAlpha] line color opacity. value range:0~255
|
|
|
+ * @param { BorderWidth } [borderWidth] border thickness, value range:0~10
|
|
|
+ * @param { object } [borderStyle] Set the border style to dashed or solid.
|
|
|
+ * @param { CPDFLineType } [startLineType] Arrow starting position shape.
|
|
|
+ * @param { CPDFLineType } [tailLineType] Arrow tail position shape.
|
|
|
+ */
|
|
|
+ arrow?: {
|
|
|
+ borderColor?: HexColor,
|
|
|
+ borderAlpha?: ColorAlpha,
|
|
|
+ borderWidth?: BorderWidth,
|
|
|
+ borderStyle?: {
|
|
|
+ /**
|
|
|
+ * default: {@link CPDFBorderStyle.SOLID}
|
|
|
+ */
|
|
|
+ style?: CPDFBorderStyle,
|
|
|
+ /**
|
|
|
+ * Dashed gap, only style={@link CPDFBorderStyle.DASHED} is valid.
|
|
|
+ */
|
|
|
+ dashGap?: DashGap
|
|
|
+ },
|
|
|
+ startLineType?: CPDFLineType
|
|
|
+ tailLineType?: CPDFLineType
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Freetext annotation attribute configuration.
|
|
|
+ * @param { HexColor } [fontColor] HEX color: #1460F3
|
|
|
+ * @param { ColorAlpha } [fontColorAlpha] text color opacity. value range:0~255
|
|
|
+ * @param { FontSize } [fontSize] font size, value range:1~100
|
|
|
+ * @param { boolean } [isBold] Whether the font is bold.
|
|
|
+ * @param { boolean } [isItalic] Is the font italicized.
|
|
|
+ * @param { CPDFAlignment } [alignment] Text alignment, {@link CPDFAlignment.LEFT} aligned by default.
|
|
|
+ * @param { CPDFTypeface } [typeface] The font used by default for text. The default is:{@link CPDFTypeface.HELVETICA}.
|
|
|
+ */
|
|
|
+ freeText?: {
|
|
|
+ fontColor?: HexColor,
|
|
|
+ fontColorAlpha?: ColorAlpha,
|
|
|
+ fontSize?: FontSize,
|
|
|
+ isBold?: boolean,
|
|
|
+ isItalic?: boolean,
|
|
|
+ alignment?: CPDFAlignment,
|
|
|
+ typeface?: CPDFTypeface
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ contentEditorConfig?: {
|
|
|
+ /**
|
|
|
+ * Content editing mode, the editing mode displayed at the bottom of the view
|
|
|
+ * Default order: editorText, editorImage
|
|
|
+ */
|
|
|
+ availableTypes?: CPDFContentEditorType[],
|
|
|
+ /**
|
|
|
+ * Available tools, including: Setting, Undo, Redo
|
|
|
+ */
|
|
|
+ availableTools?: CPDFConfigTool[]
|
|
|
+
|
|
|
+ initAttribute?: {
|
|
|
+ /**
|
|
|
+ * When adding text, the text default properties
|
|
|
+ * @param { HexColor } [fontColor] HEX color: #1460F3
|
|
|
+ * @param { ColorAlpha } [fontColorAlpha] text color opacity. value range:0~255
|
|
|
+ * @param { FontSize } [fontSize] font size, value range:1~100
|
|
|
+ * @param { boolean } [isBold] Whether the font is bold.
|
|
|
+ * @param { boolean } [isItalic] Is the font italicized.
|
|
|
+ * @param { CPDFAlignment } [alignment] Text alignment, {@link CPDFAlignment.LEFT} aligned by default.
|
|
|
+ * @param { CPDFTypeface } [typeface] The font used by default for text. The default is:{@link CPDFTypeface.HELVETICA}.
|
|
|
+ */
|
|
|
+ text?: {
|
|
|
+ fontColor?: HexColor,
|
|
|
+ fontColorAlpha?: ColorAlpha,
|
|
|
+ fontSize?: FontSize,
|
|
|
+ isBold?: boolean,
|
|
|
+ isItalic?: boolean,
|
|
|
+ alignment?: CPDFAlignment,
|
|
|
+ typeface?: CPDFTypeface
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ formsConfig?: {
|
|
|
+ /**
|
|
|
+ * In {@link CPDFViewMode.Forms} mode, the list of form types at the bottom of the view.
|
|
|
+ */
|
|
|
+ availableTypes?: CPDFFormType[]
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Only supports {@link CPDFConfigTool.UNDO} and {@link CPDFConfigTool.UNDO} .
|
|
|
+ */
|
|
|
+ availableTools?: CPDFConfigTool[]
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Form default attribute configuration
|
|
|
+ */
|
|
|
+ initAttribute?: {
|
|
|
+ /**
|
|
|
+ * Text field default properties, such as fill color, border color, text style, etc.
|
|
|
+ */
|
|
|
+ textField?: {
|
|
|
+ fillColor?: HexColor,
|
|
|
+ borderColor?: HexColor,
|
|
|
+ borderWidth?: BorderWidth,
|
|
|
+ fontColor?: HexColor,
|
|
|
+ fontSize?: FontSize,
|
|
|
+ isBold?: boolean,
|
|
|
+ isItalic?: boolean,
|
|
|
+ alignment?: CPDFAlignment,
|
|
|
+ multiline?: boolean,
|
|
|
+ typeface?: CPDFTypeface
|
|
|
+ },
|
|
|
+ checkBox?: CheckBoxAttr,
|
|
|
+ radioButton?: RadioButtonAttr,
|
|
|
+ listBox?: ListBoxAttr,
|
|
|
+ comboBox?: ComboBoxAttr,
|
|
|
+ pushButton?: {
|
|
|
+ fillColor?: HexColor,
|
|
|
+ borderColor?: HexColor,
|
|
|
+ borderWidth?: BorderWidth,
|
|
|
+ fontColor?: HexColor,
|
|
|
+ fontSize?: FontSize,
|
|
|
+ title?: string,
|
|
|
+ typeface?: CPDFTypeface,
|
|
|
+ isBold?: boolean,
|
|
|
+ isItalic?: boolean,
|
|
|
+ },
|
|
|
+ signaturesFields?: {
|
|
|
+ fillColor?: HexColor,
|
|
|
+ borderColor?: HexColor,
|
|
|
+ borderWidth?: number
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * PDF View configuration.
|
|
|
+ */
|
|
|
+ readerViewConfig?: {
|
|
|
+ linkHighlight?: boolean,
|
|
|
+ formFieldHighlight?: boolean,
|
|
|
+ displayMode?: CPDFDisplayMode,
|
|
|
+ /**
|
|
|
+ * PDF翻页是否为连续滚动
|
|
|
+ */
|
|
|
+ continueMode?: boolean,
|
|
|
+ /**
|
|
|
+ * 是否为垂直方向滚动
|
|
|
+ * true: 垂直滚动, false: 水平滚动
|
|
|
+ * 默认: true
|
|
|
+ */
|
|
|
+ verticalMode?: boolean,
|
|
|
+ /**
|
|
|
+ * 裁剪模式
|
|
|
+ * 是否裁剪PDF页面空白区域
|
|
|
+ * 默认:false
|
|
|
+ */
|
|
|
+ cropMode?: boolean,
|
|
|
+ themes?: CPDFThemes,
|
|
|
+ enableSliderBar?: boolean,
|
|
|
+ enablePageIndicator?: boolean,
|
|
|
+ /**
|
|
|
+ * 每页PDF的间距, 默认10px
|
|
|
+ */
|
|
|
+ pageSpacing?: number,
|
|
|
+ /**
|
|
|
+ * 页面缩放值, 默认1.0
|
|
|
+ */
|
|
|
+ pageScale?: number,
|
|
|
+ /**
|
|
|
+ * only android platform.
|
|
|
+ */
|
|
|
+ pageSameWidth?: boolean
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * @param { HexColor } [fillColor] HEX color: #1460F3
|
|
|
+ * @param { HexColor } [borderColor] HEX color: #1460F3
|
|
|
+ * @param { BorderWidth } [borderWidth] border thickness, value range:0~10
|
|
|
+ * @param { HexColor } [checkedColor]
|
|
|
+ * @param { boolean } [isChecked]
|
|
|
+ * @param { CPDFCheckStyle } [checkedStyle]
|
|
|
+ */
|
|
|
+export class CheckBoxAttr {
|
|
|
+ fillColor?: HexColor
|
|
|
+ borderColor?: HexColor
|
|
|
+ borderWidth?: BorderWidth
|
|
|
+ checkedColor?: HexColor
|
|
|
+ isChecked?: boolean
|
|
|
+ checkedStyle?: CPDFCheckStyle
|
|
|
+}
|
|
|
+
|
|
|
+export class RadioButtonAttr extends CheckBoxAttr{}
|
|
|
+
|
|
|
+export class ListBoxAttr {
|
|
|
+ fillColor?: string
|
|
|
+ borderColor?: string
|
|
|
+ borderWidth?: number
|
|
|
+ fontColor?: string
|
|
|
+ fontSize?: number
|
|
|
+ typeface?: CPDFTypeface
|
|
|
+ isBold?: boolean
|
|
|
+ isItalic?: boolean
|
|
|
+}
|
|
|
+
|
|
|
+export class ComboBoxAttr extends ListBoxAttr{}
|
|
|
+
|
|
|
+
|