Skip to content

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:

NameTypeDescription
darkModebooleanWhether the dark mode is active
setDarkModeReact.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:

NameTypeDescription
download() => voidA 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:

NameTypeDescription
isCompressedbooleanSpecify if the Adobe CMaps are binary packed. The default value is true
urlstringThe 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:

NameTypeDescription
isFullScreenbooleanWhether the viewer is in fullscreen mode
toggleFullScreen() => voidA function to toggle the fullscreen mode
isSupportedbooleanWhether the fullscreen mode is supported

MatchValue

The MatchValue interface represents the value of the search match.

NameTypeDescription
pagenumberThe page number of the match
pageMatchIdxnumberThe 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:

NameTypeDescription
openFile() => voidA function to open the local file to change the PDF file

The PageNavigationToolProps interface represents the properties of the page navigation tool.

This is configured via the pageNavigationTool prop of the RPSlot component:

NameTypeDescription
totalnumberThe total number of pages in a PDF file
currentnumberThe current page number
nextPage() => voidA function to navigate to the next page
prevPage() => voidA function to navigate to the previous page
changePage(page: number) => voidA function to change to a specific page number
goToPage(page: number) => SetPageResultA function to navigate to a specific page with result information

PdfPage

The PdfPage interface represents a page of React PDF Viewer.

NameTypeDescription
pagePDFPageProxyThe PDF page object
thumbnailViewportPageViewportThe thumbnail viewport of the page
thumbnailScalenumberThe 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:

NameTypeDescription
authorstringThe author of the PDF document
createdOnstringThe creation date of the PDF document
creatorstringThe creator of the PDF document
filenamestringThe name of the PDF file
fileSizestringThe size of the PDF file
keywordsstringKeywords associated with the PDF document
modifiedOnstringThe most recent modified date of the PDF document
pageCountnumber | undefinedThe total number of pages in the PDF document
pdfProducerstringThe software used to produce the PDF
pdfVersionstringThe version of the PDF specification used
subjectstringThe subject of the PDF document
titlestringThe 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:

NameTypeDescription
loadedPagesnumberThe number of pages loaded for print
totalPagesnumberThe total number of pages in the PDF document
percentagenumberThe 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:

NameTypeDescription
printPdf() => voidA function to print the PDF document
cancel() => voidA function to cancel the preparing print process
setOnProgress(callback: (progress: PreparePrintProgress) => void) => voidA function to set the print progress callback
setOnComplete(callback: () => void) => voidA function to set the print complete callback
setOnError(callback: (error: Error) => void) => voidA function to set the print error callback
progressPreparePrintProgressThe 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:

NameTypeDescription
matchCasebooleanWhether the search should be case-sensitive
wholeWordsbooleanWhether the search should be for whole words only

SetPageResult

The SetPageResult interface represents the result of setting a page in the viewer.

NameTypeDescription
successbooleanWhether the page was set successfully
currentPagenumberThe 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 with ViewMode.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:

NameTypeDescription
onClick() => voidA function to handle the thumbnail click event
activebooleanWhether 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.