Click or drag to resize

PdfViewer Class

The PDF Viewer server control for ASP.NET Web Forms.
Inheritance Hierarchy
SystemObject
  System.Web.UIControl
    System.Web.UI.WebControlsWebControl
      PdfViewer4AspNetPdfViewer

Namespace: PdfViewer4AspNet
Assembly: PdfViewerAspNet (in PdfViewerAspNet.dll) Version: 10.0
Syntax
public class PdfViewer : WebControl

The PdfViewer type exposes the following members.

Constructors
 NameDescription
Public methodPdfViewer Creates the control.
Top
Properties
 NameDescription
Public propertyAllowDownload Show or hide the download (save) button of the viewer toolbar. The default value is true.
Public propertyAllowPrint Show or hide the print button of the viewer toolbar. Printing also depends on the document permissions. The default value is true.
Public propertyClientScriptUrl The address of the client script ("~/expertpdf-viewer.ashx/expertpdf-viewer-client.js"), resolved for the page. Include it in the page to drive the viewer from JavaScript with ExpertPdfViewer.get(id).
Public propertyCurrentPage The page the document opens at. The first page in a document is page 1. A negative value means the viewer shows the first page. The default value is -1.
Public propertyDocumentDisplayMode Gets or sets the display mode of the document to show the page thumbnails, the outline (bookmarks) or the attachments next to the document. The default value is NotSet (the document's own page mode).
Public propertyLicenseKey Gets or sets the license key
Public propertyOpenPassword The password of a password protected PDF document. It is used to apply the viewer preferences and security options to a protected document. The viewer asks the user for the password of a protected document, unless the page gives it with the "passwordrequired" event of the client script.
Public propertyPageFitMode Gets or sets the fit mode of the PDF page in the viewer: the whole page (Fit), the page width (FitH) or the page height (FitV). The default value is NotSet.
Public propertyPageLayoutMode Gets or sets the layout of the pages in the viewer. The default value is OneColumn. This property also sets the page layout in the document viewer preferences.
Public propertyPdfSecurityOptions Gets a reference to the object controlling the PDF document security settings like user and owner password, and restricting printing or copying of the displayed document. The viewer honours the printing and copying permissions.
Public propertyPdfSourceBytes The PDF document to be displayed in the viewer. It is kept in the session state (when the session state is enabled) so it is displayed again after a postback.
Public propertyPdfSourceURL The address of the PDF document to be displayed in the viewer: an absolute URL, or an application relative one ("~/files/document.pdf"). If PdfSourceBytes is set, this property is ignored.
Public propertyPdfViewerPreferences Gets a reference to the object controlling the PDF document viewer preferences (hide the toolbar or the navigation panel, page mode and page layout). The preferences are written into the displayed document.
Public propertyShowDocumentPropertiesButton Show or hide the document properties command of the viewer. The default value is true.
Public propertyShowFindButton Show or hide the find button of the toolbar and its find bar (and Ctrl+F). The find methods of the client script work either way. The default value is true.
Public propertyShowNavigationPanel Show or hide the navigation panel on the left side of the viewer, with the page thumbnails, the document outline (bookmarks) and the attachments. The default value of this property is true.
Public propertyShowOpenButton Show or hide the open file command of the viewer (in the tools menu of the toolbar; Ctrl+O): the user can open a PDF file from the computer in the viewer (it is not sent to the server). The default value is false.
Public propertyShowPageNavigationButtons Show or hide the page navigation of the toolbar (previous page, next page, the page number box and the first and last page commands). The default value is true.
Public propertyShowPresentationModeButton Show or hide the presentation mode (full screen) command of the viewer. The default value is true.
Public propertyShowScrollbars Show or hide the viewer scrollbars. The document can still be scrolled with the mouse wheel and the keyboard. The default value is true.
Public propertyShowSidebarButton Show or hide the toolbar button that opens and closes the navigation panel (the panel itself can still be shown with DocumentDisplayMode). The default value is true.
Public propertyShowToolbarMode Show or hide the viewer toolbar. The default value is NotSet (the toolbar is shown).
Public propertyShowZoomButtons Show or hide the zoom buttons and the zoom list of the toolbar. The default value is true.
Public propertyViewerTheme Gets or sets the color theme of the viewer: light, dark, or as set in the browser of the user (the default). The pages of the document keep their own colors.
Public propertyZoomPercentage Gets or sets the zoom percentage of the viewer. For example, 100 represents a magnification of 100%. A negative value means the default zoom is used. The default value is -1.
Top
Methods
 NameDescription
Protected methodAddAttributesToRender Adds the viewer address and the size of the viewer frame.
(Overrides WebControlAddAttributesToRender(HtmlTextWriter))
Public methodStatic memberGetPageCount A fast method to obtain the page count of a specified PDF document.
Protected methodRender Renders the design time placeholder, or the viewer.
(Overrides WebControlRender(HtmlTextWriter))
Protected methodRenderContents The viewer frame has no content.
(Overrides WebControlRenderContents(HtmlTextWriter))
Top
Remarks

The control displays a PDF document in the page with a built-in viewer that works in every modern browser: page thumbnails, outline (bookmarks) and attachments panels, text search and selection, zoom, page layouts and printing. No browser plug-in is needed.

Set PdfSourceURL to display a document from an address, or PdfSourceBytes to display a document you have in memory (for example one you just created or converted). The viewer files are served by the control itself under the "expertpdf-viewer.ashx" address of the application; no configuration is needed (the IIS application pool must run in the Integrated pipeline mode, the default).

The page can drive the viewer from JavaScript: include "expertpdf-viewer.ashx/expertpdf-viewer-client.js" (see ClientScriptUrl) and use ExpertPdfViewer.get("ClientID") (navigation, zoom, find, theme, toolbar buttons, the password of a protected document).

See Also