ClassRadPdfViewer
Represents a control that can display and interact with PDF documents within your application. The RadPdfViewer provides comprehensive PDF viewing capabilities including zooming, scrolling, panning, and text search functionality. The control features a virtualized rendering engine to ensure optimal performance with large documents. It can be seamlessly integrated with a RadPdfViewerNavigator control to provide additional navigation features such as page thumbnails, bookmarks, and quick page selection.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.PdfViewer.dll
Syntax:
[TelerikToolboxCategory("PdfViewer")]
[Docking(DockingBehavior.Ask)]
public class RadPdfViewer : RadControl, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, INotifyPropertyChanged, ISupportInitializeNotification, ISupportInitialize, IComponentTreeHandler, ILayoutHandler, IAnalyticsProvider, IPrintable
Inheritance: objectMarshalByRefObjectComponentControlScrollableControlRadControlRadPdfViewer
Implements:
Inherited Members
Constructors
Properties
AnnotationsColor
Gets or sets the background color of the annotations when they are pressed.
Declaration
[Browsable(true)]
public Color AnnotationsColor { get; set; }
Property Value
ContainerElement
Gets the RadPdfViewerContainer which represents the elements container of the control.
Declaration
[Browsable(false)]
public RadPdfViewerContainer ContainerElement { get; }
Property Value
DefaultSize
Declaration
protected override Size DefaultSize { get; }
Property Value
Overrides
Document
Gets or Sets the currently loaded RadFixedDocument
Declaration
[Browsable(false)]
public RadFixedDocument Document { get; set; }
Property Value
EnableAISummary
Enables or disables the AI Summary feature.
Declaration
[Browsable(true)]
public bool EnableAISummary { get; set; }
Property Value
Remarks
When set to true the SummaryProvider must be assigned to generate summaries and answer questions.
EnableThumbnails
Gets or sets whether the thumbnail element is visible.
Declaration
[Browsable(true)]
public bool EnableThumbnails { get; set; }
Property Value
FitFullPage
Gets or sets whether a complete page should be fitted within the viewer control. When enabled, the zoom level automatically adjusts to display an entire page.
FitToWidth
Gets or sets whether the document should be scaled to fit the width of the viewer control. When enabled, the zoom level automatically adjusts when the control is resized.
HorizontalScrollState
Gets or sets the display state of the horizontal scrollbar.
Declaration
public ScrollState HorizontalScrollState { get; set; }
Property Value
PdfViewerElement
Gets the RadPdfViewerElement which represents the main element of the control.
Declaration
[Browsable(false)]
public RadPdfViewerElement PdfViewerElement { get; }
Property Value
PrintOrientation
Set or get the page orientation when printing.
Declaration
[Browsable(true)]
public PrintOrientation PrintOrientation { get; set; }
Property Value
PrintScalePageToPaperSize
Scale page when printing to fit the paper size without keeping the aspect ratio.
Declaration
[Browsable(false)]
public bool PrintScalePageToPaperSize { get; set; }
Property Value
RadContextMenu
Gets or sets the associated RadContextMenu. By default this is PdfViewerContextMenu.
Declaration
[Browsable(false)]
public RadContextMenu RadContextMenu { get; set; }
Property Value
ReadingMode
Gets or sets whether the entire document is loaded at the beginning or pages are loaded on demand.
Declaration
[Browsable(true)]
public ReadingMode ReadingMode { get; set; }
Property Value
RotationAngle
Gets or sets the rotation angle applied to all pages in the document.
Declaration
public RotationAngle RotationAngle { get; set; }
Property Value
ScaleFactor
Gets or sets the factor by which the document is scaled.
Declaration
[Browsable(true)]
public float ScaleFactor { get; set; }
Property Value
SelectionColor
Gets or sets the color that highlights the current selection.
Declaration
[Browsable(true)]
public Color SelectionColor { get; set; }
Property Value
ThumbnailListWidth
Get or Set the width of the Thumbnail list
UseBufferedPrinting
if true, the page will be printed in an image that will be send to the printer at once. Loss of quality is possible.
VerticalScrollState
Gets or sets the display state of the vertical scrollbar.
Declaration
public ScrollState VerticalScrollState { get; set; }
Property Value
ViewerMode
Gets or sets the current viewer mode - Pan, TextSelection or None.
Declaration
[Browsable(true)]
public FixedDocumentViewerMode ViewerMode { get; set; }
Property Value
Methods
CreateChildItems(RadElement)
Creates the child elements of the RadPdfViewer control.
Declaration
protected override void CreateChildItems(RadElement parent)
Parameters
parent
The parent element to which child elements will be added.
Overrides
CreateContainerElement(RadPdfViewerElement)
Creates the container element that hosts the PDF viewer element.
Declaration
protected virtual RadPdfViewerContainer CreateContainerElement(RadPdfViewerElement ownerElement)
Parameters
ownerElement
The PDF viewer element that will be contained.
Returns
A new instance of RadPdfViewerContainer.
CreateViewerElement()
Creates the PDF viewer element used for document visualization.
Declaration
protected virtual RadPdfViewerElement CreateViewerElement()
Returns
A new instance of RadPdfViewerElement.
ExportPage(int, double, bool, ImageFormat)
Exports a single PDF page to a Bitmap object.
Declaration
public Bitmap ExportPage(int pageNumber, double aspectRatio, bool overrideFileIfAlreadyExist, ImageFormat imageFormat)
Parameters
pageNumber
Number of the page to export. First page has a number 1. A value of 0 means export the current page.
aspectRatio
Scale factor for the exported image. Value of 1.0 represents the original size.
overrideFileIfAlreadyExist
When true, overrides the image file if it already exists.
imageFormat
The image format to use when creating the bitmap.
Returns
Returns a Bitmap object representing the PDF page. This bitmap should be disposed manually when no longer needed.
ExportPage(int, string, double, bool, ImageFormat)
Exports a single PDF page to an image file on the disk.
Declaration
public bool ExportPage(int pageNumber, string fileName, double scaleSize, bool overrideFileIfAlreadyExist, ImageFormat imageFormat)
Parameters
pageNumber
Number of the page to export. First page has a number 1. A value of 0 means export the current page.
fileName
Full path to the output image file.
scaleSize
Scale factor for the exported image. Value of 1.0 represents the original size.
overrideFileIfAlreadyExist
When true, overrides the image file if it already exists.
imageFormat
The image format to use when saving the image.
Returns
Returns true if the export was successful, false if the file already exists and overrideFileIfAlreadyExist is false.
ExportPages(double, bool, ImageFormat)
Exports all PDF pages to a collection of Bitmap objects.
Declaration
public IEnumerable<Bitmap> ExportPages(double scaleSize, bool overrideFileIfAlreadyExist, ImageFormat imageFormat)
Parameters
scaleSize
Scale factor for the exported images. Value of 1.0 represents the original size.
overrideFileIfAlreadyExist
When true, overrides existing files if encountered during the operation.
imageFormat
The image format to use when creating the bitmaps.
Returns
IEnumerable<Bitmap>
Returns a collection of Bitmap objects, one for each page in the document. These Bitmaps should be disposed manually when no longer needed.
ExportPages(string, double, bool, ImageFormat)
Exports all PDF pages to image files on the disk with sequential numbering.
Declaration
public bool ExportPages(string fileName, double scaleSize, bool overrideFileIfAlreadyExist, ImageFormat imageFormat)
Parameters
fileName
Base name for the output image files. Page numbers will be appended automatically.
scaleSize
Scale factor for the exported images. Value of 1.0 represents the original size.
overrideFileIfAlreadyExist
When true, overrides the image files if they already exist.
imageFormat
The image format to use when saving the images.
Returns
Returns true if all exports were successful, false if any file already existed and overrideFileIfAlreadyExist is false.
Find(string)
Finds the specified text in the current document using default search options.
Declaration
public SearchResult Find(string text)
Parameters
text
The text to search for in the document.
Returns
A SearchResult object containing information about the found text position or SearchResult.NotFound if the text was not found.
Find(string, TextSearchOptions)
Finds the specified text in the current document using specified search options.
Declaration
public SearchResult Find(string text, TextSearchOptions options)
Parameters
text
The text to search for in the document.
options
The search options that control case sensitivity, whole word matching, and other search parameters.
Returns
A SearchResult object containing information about the found text position or SearchResult.NotFound if the text was not found.
Find(string, TextSearchOptions, TextPosition)
Finds the specified text in the current document using specified search options and starting from a specific position. The search begins from the provided position and moves forward through the document.
Declaration
public SearchResult Find(string text, TextSearchOptions options, TextPosition startPosition)
Parameters
text
The text to search for in the document.
options
The search options that control case sensitivity, whole word matching, and other search parameters.
startPosition
The text position from which to begin searching.
Returns
A SearchResult object containing information about the found text position or SearchResult.NotFound if the text was not found.
Find(string, TextSearchOptions, TextRange)
Finds the specified text within a specific range of the current document using specified search options. The search is limited to the text content within the provided range boundaries.
Declaration
public SearchResult Find(string text, TextSearchOptions options, TextRange range)
Parameters
text
The text to search for in the document.
options
The search options that control case sensitivity, whole word matching, and other search parameters.
range
The text range within which to limit the search operation.
Returns
A SearchResult object containing information about the found text position or SearchResult.NotFound if the text was not found.
FindAll(string)
Finds all occurrences of the specified text in the current document using default search options. Returns all matching results found throughout the entire document.
Declaration
public IEnumerable<SearchResult> FindAll(string text)
Parameters
text
The text to search for in the document.
Returns
IEnumerable<SearchResult>
An enumerable collection of SearchResult objects representing all found occurrences of the text.
FindAll(string, TextSearchOptions)
Finds all occurrences of the specified text in the current document using specified search options. Returns all matching results found throughout the entire document based on the provided search criteria.
Declaration
public IEnumerable<SearchResult> FindAll(string text, TextSearchOptions options)
Parameters
text
The text to search for in the document.
options
The search options that control case sensitivity, whole word matching, and other search parameters.
Returns
IEnumerable<SearchResult>
An enumerable collection of SearchResult objects representing all found occurrences of the text.
FindAll(string, TextSearchOptions, TextPosition)
Finds all occurrences of the specified text in the current document using specified search options and starting from a specific position. Returns all matching results found from the start position to the end of the document.
Declaration
public IEnumerable<SearchResult> FindAll(string text, TextSearchOptions options, TextPosition startPosition)
Parameters
text
The text to search for in the document.
options
The search options that control case sensitivity, whole word matching, and other search parameters.
startPosition
The text position from which to begin searching.
Returns
IEnumerable<SearchResult>
An enumerable collection of SearchResult objects representing all found occurrences of the text from the start position.
FindAll(string, TextSearchOptions, TextRange)
Finds all occurrences of the specified text within a specific range of the current document using specified search options. Returns all matching results found within the boundaries of the provided text range.
Declaration
public IEnumerable<SearchResult> FindAll(string text, TextSearchOptions options, TextRange range)
Parameters
text
The text to search for in the document.
options
The search options that control case sensitivity, whole word matching, and other search parameters.
range
The text range within which to limit the search operation.
Returns
IEnumerable<SearchResult>
An enumerable collection of SearchResult objects representing all found occurrences of the text within the specified range.
FindPrevious(string)
Finds the previous occurrence of the specified text in the current document using default search options. The search begins from the current selection or position and moves backward through the document.
Declaration
public SearchResult FindPrevious(string text)
Parameters
text
The text to search for in the document.
Returns
A SearchResult object containing information about the found text position or SearchResult.NotFound if the text was not found.
FindPrevious(string, TextSearchOptions)
Finds the previous occurrence of the specified text in the current document using specified search options. The search begins from the current selection or position and moves backward through the document.
Declaration
public SearchResult FindPrevious(string text, TextSearchOptions options)
Parameters
text
The text to search for in the document.
options
The search options that control case sensitivity, whole word matching, and other search parameters.
Returns
A SearchResult object containing information about the found text position or SearchResult.NotFound if the text was not found.
FindPrevious(string, TextSearchOptions, TextPosition)
Finds the previous occurrence of the specified text in the current document using specified search options and starting from a specific position. The search begins from the provided position and moves backward through the document.
Declaration
public SearchResult FindPrevious(string text, TextSearchOptions options, TextPosition startPosition)
Parameters
text
The text to search for in the document.
options
The search options that control case sensitivity, whole word matching, and other search parameters.
startPosition
The text position from which to begin searching backward.
Returns
A SearchResult object containing information about the found text position or SearchResult.NotFound if the text was not found.
FindPrevious(string, TextSearchOptions, TextRange)
Finds the previous occurrence of the specified text within a specific range of the current document using specified search options. The search moves backward through the text content within the provided range boundaries.
Declaration
public SearchResult FindPrevious(string text, TextSearchOptions options, TextRange range)
Parameters
text
The text to search for in the document.
options
The search options that control case sensitivity, whole word matching, and other search parameters.
range
The text range within which to limit the search operation.
Returns
A SearchResult object containing information about the found text position or SearchResult.NotFound if the text was not found.
GetCurrentBookmark()
Gets the bookmark nearest to the current viewing position in the document.
Declaration
public BookmarkItem GetCurrentBookmark()
Returns
The BookmarkItem representing the nearest bookmark to the current position.
GetDocumentAsStream()
Gets the currently loaded PDF document as a stream.
Declaration
public Stream GetDocumentAsStream()
Returns
A stream containing the PDF document data.
HideAISummary()
Hides the AI summary chat in the viewer.
Declaration
public void HideAISummary()
HideBookmarks()
Hides the PDF document's bookmarks panel in the viewer.
Declaration
public void HideBookmarks()
HideSignaturePanel()
Hides the PDF document's signature panel in the viewer.
Declaration
public void HideSignaturePanel()
HideThumbnails()
Hide the Pdf document's thumbnails
Declaration
public void HideThumbnails()
IsInputKey(Keys)
Determines whether the specified key is a regular input key or a special key that requires preprocessing.
LoadDocument(Stream)
Loads a PDF document from a specified stream.
Declaration
public void LoadDocument(Stream stream)
Parameters
stream
The stream of PDF data.
LoadDocument(string)
Loads a PDF document from a specified file name.
Declaration
public void LoadDocument(string path)
Parameters
path
The path of the PDF file.
OnCaptureLosing()
Raises the CaptureLosing event. Handles cases when the control loses capture.
Declaration
protected override void OnCaptureLosing()
Overrides
OnKeyDown(KeyEventArgs)
Raises the KeyDown event. Handles keyboard input in the PDF viewer.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
e
A KeyEventArgs that contains the event data.
Overrides
OnLoad(Size)
Notifies that the control is about to be visualized.
Declaration
protected override void OnLoad(Size desiredSize)
Parameters
desiredSize
Overrides
OnMouseDown(MouseEventArgs)
Raises the MouseDown event. Handles mouse button presses over the PDF viewer.
Declaration
protected override void OnMouseDown(MouseEventArgs e)
Parameters
e
A MouseEventArgs that contains the event data.
Overrides
OnMouseMove(MouseEventArgs)
Raises the MouseMove event. Handles mouse movement over the PDF viewer.
Declaration
protected override void OnMouseMove(MouseEventArgs e)
Parameters
e
A MouseEventArgs that contains the event data.
Overrides
OnMouseUp(MouseEventArgs)
Raises the MouseUp event. Handles mouse button releases over the PDF viewer.
Declaration
protected override void OnMouseUp(MouseEventArgs e)
Parameters
e
A MouseEventArgs that contains the event data.
Overrides
OnMouseWheel(MouseEventArgs)
Declaration
protected override void OnMouseWheel(MouseEventArgs e)
Parameters
e
Overrides
OnThemeChanged()
Declaration
protected override void OnThemeChanged()
Overrides
Print()
Directly prints the RadPdfViewer to the default printer.
Declaration
public virtual void Print()
Print(bool)
Directly prints the RadPdfViewer to the default printer or shows printer settings and then prints the RadPdfViewer.
Declaration
public virtual void Print(bool showPrinterSettings)
Parameters
showPrinterSettings
Indicates whether printer settings dialog should be shown.
Print(bool, RadPrintDocument)
Directly prints the RadPdfViewer to the default printer or shows printer settings and then prints the RadPdfViewer.
Declaration
public virtual void Print(bool showPrinterSettings, RadPrintDocument document)
Parameters
showPrinterSettings
Indicates whether printer settings dialog should be shown.
document
As instance of RadPrintDocument used to control the print process.
PrintPreview()
Shows a RadPrintPreviewDialog for editing the RadPdfViewer print settings.
Declaration
public virtual void PrintPreview()
PrintPreview(RadPrintDocument)
Shows a RadPrintPreviewDialog for editing the RadPdfViewer print settings.
Declaration
public virtual void PrintPreview(RadPrintDocument document)
Parameters
document
As instance of RadPrintDocument used to control the print process.
ProcessCmdKey(ref Message, Keys)
Processes a command key. Handles Tab and Shift+Tab for navigating between form fields in the PDF document.
Declaration
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
Parameters
msg
A Message, passed by reference, that represents the Win32 message to process.
keyData
One of the Keys values that represents the key to process.
Returns
True if the character was processed by the control; otherwise, false.
Overrides
Rotate(RotationAngle)
Rotates all pages in the document to the specified angle.
Declaration
public virtual void Rotate(RotationAngle angle)
Parameters
angle
The rotation angle to apply to all pages.
SaveDocument(Stream)
Saves the currently loaded PDF document to a stream.
SaveDocument(string)
Saves the currently loaded PDF document to a file.
ScaleControl(SizeF, BoundsSpecified)
Scales the control and its contents according to the specified scaling factor.
Declaration
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
Parameters
factor
The factor by which to scale the control.
specified
A bitwise combination of BoundsSpecified values.
Overrides
Select(SearchResult)
Creates selection from start position to end position.
Declaration
public void Select(SearchResult result)
Parameters
result
The result from search.
ShowAISummary()
Show the AI summary chat for the PDF document
Declaration
public void ShowAISummary()
ShowBookmarks()
Show the Pdf document's bookmarks
Declaration
public void ShowBookmarks()
ShowSignaturePanel()
Shows the PDF document's signature panel, allowing users to view and interact with digital signatures.
Declaration
public void ShowSignaturePanel()
ShowThumbnails()
Show the Pdf document's thumbnails
Declaration
public void ShowThumbnails()
SyncCurrentBookmark()
Sync the nearest bookmark from the Pdf document's to the tree
Declaration
public void SyncCurrentBookmark()
UnloadDocument()
Unload the current PDF document.
Declaration
public void UnloadDocument()
Events
AnnotationClicked
Fires when a link or a bookmark was clicked.
Declaration
public event EventHandler<AnnotationEventArgs> AnnotationClicked
Event Value
EventHandler<AnnotationEventArgs>
CaretPositionChanged
Fires when the caret changes its position.
Declaration
public event EventHandler CaretPositionChanged
Event Value
CurrentPageChanged
Fires after the current RadFixedPage has been changed.
Declaration
public event CurrentPageChangedEventHandler CurrentPageChanged
Event Value
DataError
Fires when an internal exception in during loading parts of the document occurs. If the event is not handled, a default error message box will be shown, otherwise the message box will not show and handling the error should be done in the event handler.
Declaration
public event PdfExceptionEventHandler DataError
Event Value
DocumentLoaded
Fires when the document has finished loading.
FitFullPageChanged
Fires when the FitFullPage property has changed.
FitToWidthChanged
Fires when the FitToWidth property has changed.
HyperlinkClicked
Occurs when the hyperlink is clicked.
Declaration
public event EventHandler<HyperlinkClickedEventArgs> HyperlinkClicked
Event Value
EventHandler<HyperlinkClickedEventArgs>
PageElementCreating
Fires when a RadFixedPageElement is being created. Allows for replacing it with custom page element.
Declaration
public event RadFixedPageElementEventHandler PageElementCreating
Event Value
PageRenderCompleted
Fires when a RadFixedPageElement has been asynchronously rendered.
Declaration
public event EventHandler PageRenderCompleted
Event Value
PageRenderStarted
Fires when a RadFixedPageElement is about to be asynchronously rendered.
PdfSignaturePanelVisibilityChanged
Fires when SignaturePanel hides or shows
Declaration
public event EventHandler PdfSignaturePanelVisibilityChanged
Event Value
ScaleFactorChanged
Fires when the ScaleFactor property has changed.
SelectionChanged
Fires when the text selection has changed.
ViewerModeChanged
Fires when the ViewerMode property has changed.