Skip to content
ComPDF
Guides

Customize PDF Content Area UI

This section explains how to customize the interactive UI styles within PDF pages using readerViewConfig.uiStyle. This configuration applies only to the PDF content area itself, including visual elements such as text selection, annotation and form selection borders, screenshot selection area, page rectangle highlighting, and icons within the page. It does not include toolbar, theme colors, or overall reader UI configuration.

Annotation and Content Editor Selection Style

This configuration controls the border and control point styles of annotations and content editor objects in the selected state.

dart
CPDFConfiguration(
  readerViewConfig: CPDFReaderViewConfig(
    uiStyle: CPDFUiStyleConfig.create(
      focusBorderStyle: const CPDFUiBorderStyle(
        nodeColor: Colors.pink,
        borderColor: Colors.pink,
        borderWidth: 2,
        borderDashPattern: [0,0]
      ),
    )
  )
);
FieldTypeDescription
nodeColorStringControl point (corner) color
borderColorStringSelection border color
borderWidthNumberBorder width
borderDashPatternNumber[]Dash pattern [dash length, gap length]

Content Editor Default Border Style

This configuration controls the border display style of content editor objects in the unselected state.

dart
CPDFConfiguration(
  readerViewConfig: CPDFReaderViewConfig(
    uiStyle: CPDFUiStyleConfig.create(
      defaultBorderStyle: const CPDFUiBorderStyle(
        borderColor: Colors.amberAccent,
        borderWidth: 2,
        borderDashPattern: [20, 8]
      )
    )
  )
);
FieldTypeDescription
borderColorStringBorder color
borderWidthNumberBorder width
borderDashPatternNumber[]Dash pattern

Form Drawing and Preview Style

This configuration is used to set the drawing preview effect during form control creation.

dart
CPDFConfiguration(
  readerViewConfig: CPDFReaderViewConfig(
    uiStyle: CPDFUiStyleConfig.create(
      formPreview: CPDFUiFormPreviewStyle(
        style: CPDFFormPreviewStyleType.fill,
        color: Colors.purple.withAlpha(100),
      ),
    )
  )
);
FieldDescription
stylePreview style, supports fill / stroke
strokeWidthBorder width
colorPreview color (supports transparency)

Screenshot Selection Area Style

This configuration is used to customize the display effect of selection borders and mask areas in the screenshot function.

dart
CPDFConfiguration(
  readerViewConfig: CPDFReaderViewConfig(
    uiStyle: CPDFUiStyleConfig.create(
      screenshot: const CPDFUiScreenshotStyle(
        outsideColor: Colors.transparent,
        borderColor: Colors.purple,
        borderWidth: 5,
        borderDashPattern: [10,5],
        fillColor: Colors.transparent
      )
    )
  )
);
FieldDescription
outsideColorMask color outside selection
fillColorFill color inside selection
borderColorBorder color
borderWidthBorder width
borderDashPatternDash pattern

Text Selection Style and Operation Indicators

This configuration controls the background color of the text selection area and the operation indicator icons on both sides.

dart
CPDFConfiguration(
  readerViewConfig: CPDFReaderViewConfig(
    uiStyle: CPDFUiStyleConfig.create(
      selectTextColor: Colors.deepOrange.withAlpha(100),
      icons: const CPDFUiStyleIcons(
        selectTextIcon: 'ic_test_cursor',
        selectTextLeftIcon: 'ic_test_cursor_left',
        selectTextRightIcon: 'ic_test_cursor_right',
        rotationAnnotationIcon: 'ic_test_rotate'
      )
    )
  )
);
FieldDescription
selectTextColorText selection background color
selectTextLeftIconLeft operation indicator icon
selectTextRightIconRight operation indicator icon
selectTextIconDefault operation icon
rotationAnnotationIconRotate annotation icon

Adding Custom Icon Resources:

  • Android: Place the icon file (e.g., ic_test_cursor.png) in the android/app/src/main/res/drawable directory.
  • iOS: Add the icon file (e.g., ic_test_cursor.png) to the ios/Runner/Assets.xcassets asset catalog.

Page Rectangle Highlight Style

This configuration is used for the rectangular area style when highlighting a specified page through the controller.setDisplayPageIndex() API.

dart
CPDFConfiguration(
  readerViewConfig: CPDFReaderViewConfig(
    uiStyle: CPDFUiStyleConfig.create(
      displayPageRect: CPDFUiDisplayPageRectStyle(
        borderColor: Colors.green,
        borderWidth: 4,
        borderDashPattern: [15,5],
        fillColor: Colors.green.withAlpha(50)
      ),
    )
  )
);
FieldDescription
fillColorRectangle area fill color
borderColorRectangle border color
borderWidthBorder width
borderDashPatternDash pattern

Bookmark Marker Icon

This configuration is used to customize the display icon for bookmark markers within pages.

dart
CPDFConfiguration(
  readerViewConfig: CPDFReaderViewConfig(
    uiStyle: CPDFUiStyleConfig.create(
      bookmarkIcon: 'ic_test_bookmark',
    )
  )
);

When this field is not configured, the SDK will use the default bookmark icon.