Display Modes
ComPDF supports single-page, double-page, and book mode document layouts. It also provides page-flipping and continuous-scrolling reading modes, along with crop mode and view mode configuration.
Quick Example
The following example sets the viewer to single-page continuous mode:
- Single-page mode: disable double-page display.
- Continuous mode: enable continuous scrolling.
readerView.setDoublePageMode(false);
readerView.setContinueMode(true);Display Mode Configuration
The following table summarizes common display mode settings and the methods used to configure them:
| Option | Method | Description |
|---|---|---|
| Scroll direction | setVerticalMode(boolean vertical) | true enables vertical scrolling. false enables horizontal scrolling. |
| Single-page or double-page | setDoublePageMode(boolean doublePage) | true enables double-page display. false enables single-page display. |
| Continuous scrolling | setContinueMode(boolean continuous) | true enables continuous scrolling mode. |
| Book mode | setCoverPageMode(boolean coverPage) | Typically used with double-page mode to display the first page as a cover page. |
The following examples show how to configure each option.
Set the scroll direction:
// Vertical scrolling.
readerView.setVerticalMode(true);
// Horizontal scrolling.
readerView.setVerticalMode(false);Set single-page or double-page mode:
// Double-page display.
readerView.setDoublePageMode(true);
// Single-page display.
readerView.setDoublePageMode(false);Set continuous scrolling mode:
readerView.setContinueMode(true);Set book mode:
readerView.setDoublePageMode(true);
readerView.setCoverPageMode(true);Set the Crop Mode
Crop mode adjusts the visible page area. It is useful for hiding extra page margins and improving the use of the reading area.
This example shows how to set the crop mode:
readerView.setCropMode(true);Set the View Mode
When using CPDFReaderView, you can switch view modes with readerView.setViewMode(ViewMode viewMode) for different scenarios, such as reading, annotation editing, and document editing.
Choose a view mode based on the scenario:
VIEW: best for reading documents and filling forms.ANNOT: best for adding, deleting, and editing annotations.FORM: best for editing form structure and properties.PDFEDIT: best for editing text and images in the document.ALL: best for working with forms and annotations together.
| View Mode | Recommended for | Limitations |
|---|---|---|
| VIEW | Reading documents and filling forms | Does not support annotation addition, selection, movement, deletion, or property editing. Does not support form addition, selection, movement, deletion, or property editing. |
| ANNOT | Adding, deleting, and editing annotations | Does not support form filling. Does not support form addition, selection, movement, deletion, or property editing. Does not support document text or image editing. |
| FORM | Editing form structure and properties | Does not support annotation addition, selection, movement, deletion, or property editing. Does not support form filling. |
| PDFEDIT | Editing document text and images | Does not support annotation addition, selection, movement, deletion, or property editing. Does not support form filling. Does not support form addition, selection, movement, deletion, or property editing. |
| ALL | Working with forms and annotations together | Does not support form filling. Does not support document text or image editing. |