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.

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

Localization

Currently, React PDF Viewer component comes with built-in translations of 5 languages, namely: The default localizations provided are:

  • en_US (English - United States)
  • it_IT (Italian - Italy)
  • pt_PT (Portuguese - Portugal)
  • th_TH (Thai - Thailand)
  • zh_CN (Chinese - China)

To change the translations, React PDF Viewer provides localization keys for easy customization. Each key corresponds to a specific text that will be displayed in the component for each locale.

Here are the keys you can localize:

KeyTypeDescription
currentPageTooltipstringTooltip text of the current page
documentPropertiesLabelstringLabel of the document properties option in More Options and the title of document properties modal
documentPropertiesTooltipstringTooltip text of the document properties option
downloadFileLabelstringLabel of the download icon
downloadFileTooltipstringTooltip text of the download icon
dragDropFileMessagestringMessage of the drag & drop mask when a file is dragged over the component
dualPageLabelstringLabel of the dual page panel in More Options
dualPageTooltipstringTooltip text of the dual page option
firstPageTooltipstringTooltip text of the first page option
fullScreenLabelstringLabel of the full screen option in More Options on mobile responsive
fullScreenTooltipstringTooltip text of the full screen button and the full screen option
handToolLabelstringLabel of the hand tool option in More options
handToolTooltipstringTooltip text of the hand tool option
horizontalScrollingLabelstringLabel of the horizontal scrolling option in More Options
horizontalScrollingTooltipstringTooltip text of the horizontal scrolling option
lastPageLabelstringLabel of the last page option in More Options
lastPageTooltipstringTooltip text of the last page option
moreOptionTooltipstringTooltip text of the More Options button
nextPageTooltipstringTooltip text of the next page button
openLocalFileLabelstringLabel of open local file option within More Options on mobile responsive
openLocalFileTooltipstringTooltip text of the open local file button and open local file option
pageScrollingLabelstringLabel of the page scrolling option in More Options
pageScrollingTooltipstringTooltip text of the page scrolling option
previousPageTooltipstringTooltip text of the previous page button
printCancelLabelstringLabel of the button to cancel printing process
printLabelstringLabel of print option in More Options on mobile responsive
printLoadingMessagestringLoading message on the progress modal while preparing printing
printTooltipstringTooltip text of the print button and the print option
propertiesAuthorLabelstringLabel of the author in document properties modal
propertiesCreateOnLabelstringLabel of the created date in document properties modal
propertiesCreatorLabelstringLabel of the creator in document properties modal
propertiesFilenameLabelstringLabel of the filename in document properties modal
propertiesFileSizeLabelstringLabel of the file size in document properties modal
propertiesKeywordLabelstringLabel of the keyword in document properties modal
propertiesModifiedOnLabelstringLabel of the modified date in document properties modal
propertiesPageCountLabelstringLabel of the page count in document properties modal
propertiesPDFProducerLabelstringLabel of the PDF producer in document properties modal
propertiesPDFVersionLabelstringLabel of the PDF version in document properties modal
propertiesSubjectLabelstringLabel of the subject in document properties modal
propertiesTitleLabelstringLabel of the title in document properties modal
rotateClockwiseLabelstringLabel of the rotate clockwise option in More Options
rotateClockwiseTooltipstringTooltip text of the rotate clockwise option
rotateCounterclockwiseLabelstringLabel of the rotate counterclockwise option in More Options
rotateCounterclockwiseTooltipstringTooltip text of the rotate counterclockwise option
searchButtonTooltipstringTooltip text of the search button
searchCloseButtonTooltipstringTooltip text of the close icon for the search popover
searchInputPlaceholderstringPlaceholder of the search input
searchInputTooltipstringTooltip text of the search input
searchNextTooltipstringTooltip text of the next search match icon
searchMatchCaseLabelstringLabel of the search match case option
searchMatchCaseTooltipstringTooltip text of the search match case option
searchPrevTooltipstringTooltip text of the previous search match icon
searchWholeWordsLabelstringLabel of the search whole words option
searchWholeWordsTooltipstringTooltip text of the search whole words option
singlePageLabelstringLabel of the single page panel option in More Options
singlePageTooltipstringTooltip text of the single page option
textSelectionLabelstringLabel of the text selection option in More Options
textSelectionTooltipstringTooltip text of the text selection option
themeEnableDarkTooltipstringTooltip text of the button to enable dark theme
themeEnableLightTooltipstringTooltip text of the button to enable light theme
thumbnailTooltipstringTooltip text of the thumbnail button
verticalScrollingLabelstringLabel of the vertical scrolling option in More Options
verticalScrollingTooltipstringTooltip text of the vertical scrolling option
zoomActualSizestringLabel of the actual zoom option of the zoom menu select
zoomInTooltipstringTooltip text of the zoom in button
zoomOutTooltipstringTooltip text of the zoom out button
zoomPageFitstringLabel of the page fit zoom option of the zoom menu select
zoomPageWidthstringLabel of the page width zoom option of the zoom menu select
zoomSelectTooltipstringTooltip text of the selector between zoom buttons

If you would like to add a custom language instead, follow here for our Adding a Custom Localization tutorial

Remark: If you would like to request another built-in language, please submit a request on GitHub.

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.

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 React PDF.

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.