Skip to content

Get Default Config

Method: getDefaultConfig()

When you use the ComPDFKit.openDocument method to present a PDF file, you need to pass configuration parameters to customize the UI features and PDF view properties. ComPDFKit provides default configuration parameters through ComPDFKit.getDefaultConfig. You can retrieve them using the following example:

tsx
ComPDFKit.getDefaultConfig({})

You can modify certain parameters to meet your requirements. Here are some usage examples:

  1. Setting the initial display mode and available mode list. The following code is an example that enables only the viewer mode and annotation mode:
tsx
ComPDFKit.getDefaultConfig({
  modeConfig: {
    initialViewMode: CPDFViewMode.VIEWER,
    availableViewModes: [
      CPDFViewMode.VIEWER,
      CPDFViewMode.ANNOTATIONS
    ]
  }
})
  1. Setting the enabled annotation types and the default annotation attribute values list. For example, enabling only note annotations and setting the color and transparency of note annotations:
tsx
ComPDFKit.getDefaultConfig({
  annotationsConfig:{
    availableType:[
      CPDFAnnotationType.NOTE
    ],
    availableTools:[
      CPDFConfigTool.SETTING,
      CPDFConfigTool.UNDO,
      CPDFConfigTool.REDO
    ],
    initAttribute:{
      note:{
        color: '#1460F3',
        alpha: 255
      }
    }
  }
})

3.Setting the display mode and page turning direction:

tsx
ComPDFKit.getDefaultConfig({
  readerViewConfig:{
    displayMode: CPDFDisplayMode.DOUBLE_PAGE,
    verticalMode: false
  }
})

For more configuration parameter descriptions, please see CPDFCONFIGURATION.md.