Interfaces
The interfaces and enumerators described here are used across different components and hooks to ensure consistent data structures and type checking.
Below you’ll find detailed documentation for each interface and enumeration, including relationships to other parts of React PDF Viewer.
DarkModeProps
The DarkModeProps
interface represents the properties of the dark mode.
This is configured via the themeSwitcher
prop of the RPSlot
component:
Name | Type | Description |
---|---|---|
darkMode | boolean | Whether the dark mode is active |
setDarkMode | React.Dispatch<React.SetStateAction<boolean>> | A function to set the dark mode |
DownloadToolProps
The DownloadToolProps
interface represents the properties of the download tool.
This is configured via the downloadTool
prop of the RPSlot
component:
Name | Type | Description |
---|---|---|
download | () => void | A function to download the PDF file |
CharacterMap
The CharacterMap
interface represents the character map object of (CMap) to be used for text rendering.
This is configured via the characterMap
prop of the RPProvider
component:
Name | Type | Description |
---|---|---|
isCompressed | boolean | Specify if the Adobe CMaps are binary packed. The default value is true |
url | string | The URL or relative path where the predefined Adobe CMaps are located. It must have / at the end |
FullScreenToolProps
The FullScreenToolProps
interface represents the properties of the full screen tool.
This is configured via the fullscreenTool
prop of the RPSlot
component:
Name | Type | Description |
---|---|---|
isFullScreen | boolean | Whether the viewer is in fullscreen mode |
toggleFullScreen | () => void | A function to toggle the fullscreen mode |
isSupported | boolean | Whether the fullscreen mode is supported |
MatchValue
The MatchValue
interface represents the value of the search match.
Name | Type | Description |
---|---|---|
page | number | The page number of the match |
pageMatchIdx | number | The index of the match in the page |
OpenFileToolProps
The OpenFileToolProps
interface represents the properties of the open file tool.
This is configured via the openFileTool
prop of the RPSlot
component:
Name | Type | Description |
---|---|---|
openFile | () => void | A function to open the local file to change the PDF file |
PageNavigationToolProps
The PageNavigationToolProps
interface represents the properties of the page navigation tool.
This is configured via the pageNavigationTool
prop of the RPSlot
component:
Name | Type | Description |
---|---|---|
total | number | The total number of pages in a PDF file |
current | number | The current page number |
nextPage | () => void | A function to navigate to the next page |
prevPage | () => void | A function to navigate to the previous page |
changePage | (page: number) => void | A function to change to a specific page number |
goToPage | (page: number) => SetPageResult | A function to navigate to a specific page with result information |
PdfPage
The PdfPage
interface represents a page of React PDF Viewer.
Name | Type | Description |
---|---|---|
page | PDFPageProxy | The PDF page object |
thumbnailViewport | PageViewport | The thumbnail viewport of the page |
thumbnailScale | number | The thumbnail scale of the page |
PdfProperties
The PdfProperties
interface represents metadata and properties of a PDF document.
These properties can be accessed from the onLoaded
event of the RPProvider
component and the useDocumentContext
hook:
Name | Type | Description |
---|---|---|
author | string | The author of the PDF document |
createdOn | string | The creation date of the PDF document |
creator | string | The creator of the PDF document |
filename | string | The name of the PDF file |
fileSize | string | The size of the PDF file |
keywords | string | Keywords associated with the PDF document |
modifiedOn | string | The most recent modified date of the PDF document |
pageCount | number | undefined | The total number of pages in the PDF document |
pdfProducer | string | The software used to produce the PDF |
pdfVersion | string | The version of the PDF specification used |
subject | string | The subject of the PDF document |
title | string | The title of the PDF document |
PreparePrintProgress
The PreparePrintProgress
interface represents the progress of the print process.
This is used in the setOnProgress
callback and the progress
prop of the PrintToolProps
interface:
Name | Type | Description |
---|---|---|
loadedPages | number | The number of pages loaded for print |
totalPages | number | The total number of pages in the PDF document |
percentage | number | The progress of the print process |
PrintToolProps
The PrintToolProps
interface represents the properties of the print tool.
This is configured via the printTool
prop of the RPSlot
component:
Name | Type | Description |
---|---|---|
printPdf | () => void | A function to print the PDF document |
cancel | () => void | A function to cancel the preparing print process |
setOnProgress | (callback: (progress: PreparePrintProgress) => void) => void | A function to set the print progress callback |
setOnComplete | (callback: () => void) => void | A function to set the print complete callback |
setOnError | (callback: (error: Error) => void) => void | A function to set the print error callback |
progress | PreparePrintProgress | The progress object of the print process |
SearchOptions
The SearchOptions
interface represents the options for searching text in the React PDF Viewer.
This is configured via the searchOptions
prop of the useSearchContext
hook:
Name | Type | Description |
---|---|---|
matchCase | boolean | Whether the search should be case-sensitive |
wholeWords | boolean | Whether the search should be for whole words only |
SetPageResult
The SetPageResult
interface represents the result of setting a page in the viewer.
Name | Type | Description |
---|---|---|
success | boolean | Whether the page was set successfully |
currentPage | number | The current page number |
ScrollMode
The ScrollMode
enumeration is used to define how pages will be scrolled in the viewer. This is configured via the initialScrollMode
prop:
ScrollMode.HORIZONTAL_SCROLLING
: Pages are scrolled horizontally. This mode is compatible withViewMode.SINGLE_PAGE
only.ScrollMode.PAGE_SCROLLING
: Displays one page at a time, enabling users to scroll through individual pages.ScrollMode.VERTICAL_SCROLLING
: Pages are scrolled vertically, displaying multiple pages stacked on top of each other.
ThumbnailToolProps
The ThumbnailToolProps
interface represents the properties of the thumbnail tool.
This is configured via the thumbnailTool
prop of the RPSlot
component:
Name | Type | Description |
---|---|---|
onClick | () => void | A function to handle the thumbnail click event |
active | boolean | Whether the thumbnail is active |
ZoomLevel
The ZoomLevel
enumeration defines how pages will be scaled in the viewer. This is configured via the initialScale
prop:
ZoomLevel.ACTUAL
: Pages are rendered at their actual PDF size.ZoomLevel.PAGE_FIT
: Pages are scaled to fit within the viewer’s width and height.ZoomLevel.PAGE_WIDTH
: Pages are scaled to fit the viewer’s width.