DocumentViewer Class

The ASP.NET component for viewing several formats of documents.

Definition

Namespace: GleamTech.DocumentUltimate.AspNet.UI
Assembly: GleamTech.DocumentUltimate (in GleamTech.DocumentUltimate.dll) Version: 6.6.1
C#
public sealed class DocumentViewer : StatefulComponent<DocumentViewerState>
Inheritance
Object    Component    StatefulComponent    StatefulComponentDocumentViewerState    DocumentViewer

Example

C#
@using GleamTech.AspNet.Mvc
@using GleamTech.DocumentUltimate
@using GleamTech.DocumentUltimate.AspNet
@using GleamTech.DocumentUltimate.AspNet.UI

<!DOCTYPE html>
@{
    var documentViewer = new DocumentViewer
    {
        Width = 800,
        Height = 600,
        Document = "~/Documents/Document.docx"
    };
}
<html>
    <head>
        <title>Document Viewer</title>
        @this.RenderHead(documentViewer)
    </head>
    <body>
        @this.RenderBody(documentViewer)
    </body>
</html>

Note that for ASP.NET Core, you also need to add and register GleamTech in Startup.cs, please see Using DocumentUltimate in an ASP.NET Core project.

Constructors

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

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 StatefulComponent)
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 component is rendered as InPlace (default), Panel, Window or Viewport.
(Inherited from Component)
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 FileSystemFileProvider with PhysicalLocation. 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.
    (e.g. "http://example.com/SomeFolder/SomeFile.ext").

    This is parsed as UrlFileProvider. HTTP and HTTPS (SSL) links are supported.

  • 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 component.
(Inherited from Component)
Hidden Gets or sets a value indicating whether the component is displayed when page is loaded. When set to false, the component can be displayed later on client-side manually. For example, the component can be displayed via a button's click event.
(Inherited from Component)
Id Gets or sets the HTML id of the component. Also a javascript variable with the same name is automatically defined and it can be used to access the client-side implementation of the component. If omitted, Id will be automatically set to the class name of this component (e.g camel-case className) and if there are other instances on the same page, to className2 ... classNameX.
(Inherited from Component)
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 Component)
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 Component)
Resizable Gets or sets a value that specifies if the component can be resized when the user drags sides.
(Inherited from Component)
ResizeHandles Gets or sets a value that specifies the handles which can be used for resizing the component. Default is South, East and SouthEast. When using Window mode, set ResizeHandles which overrides this property.
(Inherited from Component)
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 component. This is determined automatically when state is saved to session.
(Inherited from StatefulComponent)
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 component.
(Inherited from Component)
WindowOptionsGets or sets the windows options used for Window mode.
(Inherited from Component)

See Also