Toolbar Tools
The PDFViewer component toolbar provides various tools that enable users to interact with the PDFViewer component and perform different actions over the displayed PDF content. This article describes the built-in tools and shows how to customize them.
By default, the PDFViewer displays all its built-in tools. To display only the required tools or change their order, set the tools
property of the component to PDFViewerTool
array.
The available tools are:
pager
—Allows you to navigate through the pages.spacer
—Enables you to define spacing between the toolbar inner elements.zoomInOut
—Displays buttons for zooming in and out.zoom
—Renders a ComboBox component for setting predefined or custom zoom levels (default value is125%
).selection
—Allows you to customize the pointer functionality within the PDF document withPointer
andHand
modes.search
—Enables the search functionality.open
—Allows you to select a PDF document from the file system.download
—Enables you to download the viewed PDF document.print
—Opens the browser print window.annotations
—Enables you to add and manage annotations within the PDF document.
The following example demonstrates how to reorder the built-in tools by setting the tools
property of the PDFViewer.
Pager Tool
The pager tool allows you to navigate through the PDFViewer pages when the displayed PDF contains more than on page.
For the pager to work, set the height of the PDFViewer to be smaller than the height of the loaded document.
The following example demonstrates the pager tool of the PDFViewer in action.
Programmatically Scrolling the PDFViewer
The PDFViewer lets you scroll to a specific page programmatically by using its scrollToPage()
method. This method accepts as a parameter the page number to which you desire to scroll, treating 0 as the first page of the document.
The following example demonstrates how to programmatically scroll to a specific page in the PDFViewer.
Search Tool
The searching tool enables you to find a specific word or phrase inside the PDF document. Navigate through the results by using the Up and Down arrows.
The number of pages in the loaded PDF document might affect the performance of the PDFViewer search functionality. In case the performance falls below acceptable levels, consider removing the search tool to ensure optimal user experience.
The following example demonstrates the search tool of the PDFViewer in action.
Zooming Tools
The PDFViewer component provides multiple ways to zoom in and out of a PDF document:
- Use the ZoomIn and ZoomOut buttons of the
zoomInOut
tool. The default zoom rate is 0.25 (25%), but you can customize it by setting thezoomRate
property. - Select a predefined zoom level or set a custom one using the
zoom
tool. - Configure the initial zoom level by setting the
zoom
property. The available options include:- A numeric value—Lets you set a custom zoom level. The default value is
1.25
, which equals 125%. fitToPage
—Adjusts the PDF document to fit within the available vertical space, ensuring the entire page is visible.fitToWidth
—Adjusts the PDF document to fit within the available horizontal space.
- A numeric value—Lets you set a custom zoom level. The default value is
- Hold the
Ctrl
orCmd
(Mac) key while scrolling the mouse wheel to zoom in or out.
Additionally, you can restrict the zoom levels by setting the minZoom
and maxZoom
properties.
The following example demonstrates the zoom
property and the available zooming tools in action.
Selection Tool
The selection tool allows you to customize the pointer functionality within the PDF document:
- Pointer Mode—Use the pointer icon to highlight text or interact with clickable elements, such as links, within the document.
- Hand Mode—Use the hand icon to scroll through the document by dragging the content.
The following example demonstrates the selection tools of the PDFViewer component.
Spacer
The spacer allows you to define spacing between the toolbar inner elements. It is useful when you want to group certain tools together or create visual separation between different sections of the toolbar.
<kendo-pdfviewer [tools]="['pager', 'spacer', 'zoomInOut', 'spacer', 'zoom', 'spacer', 'selection', 'search', 'open', 'download', 'print', 'annotations']">
</kendo-pdfviewer>
Download Tool
The download tool allows you to download the viewed document. You can configure the name of the file by setting the saveFileName
option. Set the saveOptions
property to further configure proxy URLs, targets and others. The saveOptions
property accepts a SaveOptions
object.
The following example demonstrates the download tool of the PDFViewer component and how to set the file name of the downloaded file.
Open Tool
The PDFViewer allows you to open a PDF file from your local file system. This is extremely useful when you want to preview and validate the selected PDF, before proceeding with a certain action.
The following example demonstrates the open tool of the PDFViewer component.
Print Tool
The print tool opens the browser print window which enables you to configure and print the document.
The following example demonstrates the upload tool of the PDFViewer component.
Annotations Tool
The annotations tool enables you to add and manage annotations within the PDF document to enhance its content. This tool is only active when the text selection tool is enabled and provides highlighting and free text annotation capabilities.
The PDFViewer creates a dedicated layer for annotations and includes them when downloading or printing the file. If you open a file with existing annotations, you can only edit annotations that were added using the PDFViewer Annotations
tool. The PDFViewer does not support editing annotations added in other PDF editors.
To access the annotations functionality, click the Annotations
button in the toolbar. This opens a dedicated annotations toolbar with the available annotation types.
The Annotations tool is only active when text selection tool is enabled.
The following example demonstrates the annotations tool of the PDFViewer component.
Supported Annotation Types
The PDFViewer provides the following annotation types:
Annotation Type | Description |
---|---|
Text Highlight | Allows highlighting selected text in the document. Users can choose the desired highlight color. |
Free Text | Allows creating text elements anywhere in the document with customizable text color and font size. |
Working with Annotations
To manage annotations, follow these steps:
- Enable Text Selection mode—The annotations tool is only available when the selection tool is enabled.
- Open the Annotations toolbar—Click the Annotations button in the main toolbar to reveal the annotations toolbar.
- Select an annotation type—Click the desired annotation type (Highlight or Free Text) to activate it.
Once you enable the annotations and select an annotation type, you can create or edit annotations.
Creating Annotations
- Text Highlight—Double-click on a word to highlight it, or drag to select and highlight a text range.
- Free Text—Click anywhere on the document canvas to open the free text editor.
Editing Annotations
- Select annotations—Click on an existing annotation to select it. Hold
Ctrl
(orCmd
on Mac) and click to select multiple annotations of the same type. - Edit properties—Selected annotations display a toolbar with Edit and Delete options:
- Edit opens a color picker for highlights or font/color options for free text
- Delete shows a confirmation dialog before removing the annotation
- Edit free text content—Double-click a free text annotation to edit its text content.
- Move free text—Click and drag a free text annotation to reposition it.