DocumentViewerControl Class

The ASP.NET Web Forms control for viewing several formats of documents.

Definition

Namespace: GleamTech.DocumentUltimate.AspNet.WebForms
Assembly: GleamTech.DocumentUltimate (in GleamTech.DocumentUltimate.dll) Version: 6.9.6
C#
public sealed class DocumentViewerControl : StatefulComponentControl<DocumentViewer>
Inheritance
Object    Control    WebControl    ComponentControlDocumentViewer    StatefulComponentControlDocumentViewer    DocumentViewerControl

Example

ASPX
<%@ Register TagPrefix="GleamTech" Namespace="GleamTech.DocumentUltimate" Assembly="GleamTech.DocumentUltimate" %>
<%@ Register TagPrefix="GleamTech" Namespace="GleamTech.DocumentUltimate.AspNet.WebForms" Assembly="GleamTech.DocumentUltimate" %>

<!DOCTYPE html>
<html>
    <head runat="server">
        <title>Document Viewer</title>
    </head>
    <body>

        <GleamTech:DocumentViewerControl runat="server" 
            Width="800" 
            Height="600" 
            Document="~/Documents/Document.docx" />

    </body>
</html>

Constructors

DocumentViewerControl Initializes a new instance of the DocumentViewerControl class.
DocumentViewerControl(DocumentUltimateWebConfiguration) Initializes a new instance of the DocumentViewerControl class with custom web configuration.
DocumentViewerControl(DocumentViewer) Initializes a new instance of the DocumentViewerControl class with an existing DocumentViewer component instance.

Properties

AllowedPermissions Gets or sets a value that specifies the allowed permissions for the document viewer. The default is All.

DeniedPermissions take precedence over AllowedPermissions. For instance, when AllowedPermissions is set to All and DeniedPermissions is set to Download and Print, all permissions except Download and Print will be allowed.

When combining permissions, they should be separated by comma in string and by bitwise 'or' operator in code (| in C# and OR in VB).

ClientEventsGets or sets the client-side event handlers.
DebugMode Gets or sets a value indicating whether to display detailed error messages for troubleshooting. Exceptions will be displayed with stack trace, inner exceptions and data.
(Inherited from StatefulComponentControlDocumentViewer)
DeniedPermissions Gets or sets a value that specifies the denied permissions for the document viewer. The default is None.

DeniedPermissions take precedence over AllowedPermissions. For instance, when AllowedPermissions is set to All and DeniedPermissions is set to Download and Print, all permissions except Download and Print will be allowed.

When combining permissions, they should be separated by comma in string and by bitwise 'or' operator in code (| in C# and OR in VB).

DisplayLanguage Gets or sets the display (user interface) language of the document viewer.

It is usually set as the two-letter language names like en, de, fr etc. as the bundled languages are usually for general language names. However it can be also set to specific cultures like en-US, de-DE, fr-FR etc. For example, if the property is set to a specific culture like de-CH (German in Switzerland), the component will first look for the language file translation-de-CH.json and if the file is not found, it will load the general (fallback) language file of that culture which is translation-de.json. If not set, the language file which matches the current UICulture of the host application will be loaded. If there is no language file which matches the current UICulture or its fallback, then the default language file translation-en.json is loaded.

DisplayModeGets or sets a value indicating whether the control is rendered as InPlace (default), Panel, Window or Viewport.
(Inherited from ComponentControlDocumentViewer)
Document Gets or sets the document to load and display in the document viewer.

This property can be set to:

  • A plain string which contains a physical/virtual path
    (e.g. "c:\SomeFolder\SomeFile.ext", "/SomeFolder/SomeFile.ext", "~/SomeFolder/SomeFile.ext").

    This is parsed as a FileSystemFileProvider instance with a PhysicalLocation instance. Note that virtual paths can only be resolved in a web application.
    and on Linux paths starting with "/" are physical paths and not virtual paths.

  • A plain string which contains a URL or a Data URL.
    (e.g. "http://example.com/SomeFolder/SomeFile.ext", "data:image/gif;base64,...").

    Strings starting with http:// or https:// are parsed as a UrlFileProvider instance.
    Strings starting with data: are parsed as a DataUrlFileProvider instance.

  • A FileProvider instance created with one of the builtin file providers
    (e.g. FileSystemFileProvider, UrlFileProvider, DataUrlFileProvider, StreamFileProvider, MemoryFileProvider, DatabaseFileProvider, AssemblyResourceFileProvider, TemporaryFileProvider).

    You can also override FileProvider base class to implement your custom file provider.

  • A provider string which defines a specific file provider
    (e.g. "Type=FileSystem; File=SomeFile.ext; Location='Type=Physical; Path=c:\SomeFolder'").

The document viewer only needs a readable file provider as it only calls GetInfo and OpenRead.

DocumentOptions Gets or sets the options for the document loaded in the document viewer.

You can specify document format, password, watermarks, attachments etc.

FormatLanguage Gets or sets the format language of the document viewer.

Format language is used for the number and date/time formats. It is usually set as the specific cultures like en-US, de-DE, fr-FR etc. If not set, the current Culture of the host application will be used.

HeightGets or sets the height of the control.
(Inherited from ComponentControlDocumentViewer)
Hidden Gets or sets a value indicating whether the control is displayed when page is loaded. When set to false, the control can be displayed later on client-side manually. For example, the control can be displayed via a button's click event.
(Inherited from ComponentControlDocumentViewer)
ID Gets or sets the control id and HTML id of the control. Also a javascript variable with the same name is automatically defined and it can be used to access the client-side implementation of the control. If omitted, Id will be automatically set to the class name of this control (e.g camel-case className without Control suffix) and if there are other instances on the same page, to className2 ... classNameX.
(Inherited from ComponentControlDocumentViewer)
LoadingMessage Gets or sets a value that specifies the message displayed while the document is being prepared for the first-time viewing. For example, you can override the default message for localization purpose.
MobileMode Gets or sets a value that specifies which mobile device type to use mobile document viewer on. The default is OnAny.

Note that using full document viewer on mobile devices would cause performance issues (slow rendering), so you should prefer mobile document viewer which is optimized for mobile devices.

PageFitMode Gets or sets a value that specifies the initial mode for fitting pages in the document viewer. The default is FitWidth.
PageLayoutMode Gets or sets a value that specifies the initial mode for placing pages in the document viewer. The default is Continuous.
PageRotationMode Gets or sets a value that specifies whether rotate buttons should only rotate all pages or only the currently viewed page. The default is AllPages.
PageZoomLevel Gets or sets a value in percentage that specifies the initial zoom level in the document viewer. The default is 100.

For this property to be effective PageFitMode property should be set to Zoom.

PanelOptionsGets or sets the panel options used for Panel mode.
(Inherited from ComponentControlDocumentViewer)
PrintOptions Gets or sets the print options of the document viewer.

The options will be reflected as default values on the print dialog of the document viewer.

ProductInfoRenderedGets or sets a value indicating whether product info/copyright comment is rendered in html.
(Inherited from ComponentControlDocumentViewer)
Resizable Gets or sets a value that specifies if the control can be resized when the user drags sides.
(Inherited from ComponentControlDocumentViewer)
ResizeHandles Gets or sets a value that specifies the handles which can be used for resizing the control. Default is South, East and SouthEast. When using Window mode, set ResizeHandles which overrides this property.
(Inherited from ComponentControlDocumentViewer)
SearchOptions Gets or sets the text search options of the document viewer.

If you specify a search term, an automatic search will be done when the document is displayed, i.e. the specified term will be searched and results with clickable positions will be listed on the left pane and the term will be highlighted in the pages. For example, if you launch the document viewer from a search results page, you can pass the same search term to the document viewer.

SidePaneTabsAtBottom Gets or sets a value that specifies whether the top tabs of the left side pane should be placed at the bottom instead. The default is false.
SidePaneVisible Gets or sets a value that specifies whether the left side pane is visible. The default is true.
StateId Gets or sets the state id of the control. This is determined automatically when state is saved to session.
(Inherited from StatefulComponentControlDocumentViewer)
ToolbarAtBottom Gets or sets a value that specifies whether the top toolbar should be placed at the bottom instead. The default is false.
ToolbarVisible Gets or sets a value that specifies whether the top toolbar is visible. The default is true.
WidthGets or sets the width of the control.
(Inherited from ComponentControlDocumentViewer)
WindowOptionsGets or sets the windows options used for Window mode.
(Inherited from ComponentControlDocumentViewer)

See Also