ASP.NET Core

For ASP.NET Core applications, DS Server provides 3 different NuGet packages:

Prerequisites

The following prerequisites must be fulfilled to use the DS Server ASP.NET MVC NuGet packages.

Security Profiles

In order to use the ASP.NET Core MVC NuGet packages, a running DS Server with valid security profiles is required. Learn how to setup the security profiles in this chapter:

Creating Security Profiles

.NET Core Version

The following .NET Core versions are supported:

  • .NET Core 3.1

  • .NET Core 5

DocumentEditor

This library offers a HTML5 based document editor to create and modify MS Word documents browser including Google Chrome, Firefox, Safari and Edge.

Installation

Install-Package TXTextControl.DocumentServices.DocumentEditor

Usage

The library implements an HTML Helper for MVC Razor applications. The following sample code shows how to add the editor to an MVC view:

@using TXTextControl.DocumentServices.DocumentEditor;

@Html.TXTextControl().DocumentEditor(s => {
    s.Width = "800px";
    s.Height = "600px";
    s.ServiceUrl = "https://yourdomain.com/DocumentServices";
    s.OAuthSettings.ClientId = "dsserver.ZVOL4OPU664IqA0NMJAisrX2iCeLaOmo";
    s.OAuthSettings.ClientSecret = "faZwTMHRe0VgKfyvMgD8FM8eOKymEst3";
    s.OAuthSettings.RedirectUri = "https://yourdomain.com/DocumentEditor/textcontrol/DocumentEditor/auth/callback";
}).Render()

Trial Token

If you are evaluating DS Server and you are using a trial token, remove the third parameter in the OAuthSettings (RedirectUri) and replace the ServiceUrl with the demo server location https://trial.dsserver.io.


@using TXTextControl.DocumentServices.DocumentEditor;

@Html.TXTextControl().DocumentEditor(s => {
    s.Width = "800px";
    s.Height = "600px";
    s.ServiceUrl = "https://trial.dsserver.io";
    s.OAuthSettings.ClientId = "dsserver.ZVOL4OPU664IqA0NMJAisrX2iCeLaOmo";
    s.OAuthSettings.ClientSecret = "faZwTMHRe0VgKfyvMgD8FM8eOKymEst3";
}).Render()

Available Properties

Property Value Type Description
Width string Specifies the width of the document editor. All CSS length values are possible (e. g. "100%" or "20em" etc.).
Height string Specifies the height of the document editor. All CSS length values are possible (e. g. "100%" or "20em" etc.).
Position CSSPosition Specifies the CSS position of the document editor.
Culture CultureInfo Gets or sets the control's culture. Affects date and time string formats, for example.
UICulture CultureInfo Gets or sets the control's user interface culture. Affects the string resource language.
UICulture CultureInfo Gets or sets the control's user interface culture. Affects the string resource language.
DocumentData byte[] Specifies the document data from where to load the document to edit. For text based document file formats this must be utf-8 data.
EditMode EditMode Gets or sets a value indicating whether the document's text is protected, or can be freely edited and formatted.
FormattingPrinter string The name of a printer the text dimensions and capabilities of which are used to format the document.
ReconnectTimeout int Time in seconds before stopping reconnection attempts after a connection loss.
DocumentFileFormat StreamType Specifies the document file format of the document data provided via the DocumentData property.
JsonData string The data source for the reporting tab.
ServiceUrl string The service URL.
OAuthSettings OAuthSettings Specifies the OAuth settings.
UserNames string[] Gets or sets the available user names.

Custom Objects

CSSPosition Enum

Value Description
Static The element is positioned according to the normal flow of the document. The top, right, bottom, left, and z-index properties have no effect. This is the default value.
Relative The element is positioned according to the normal flow of the document, and then offset relative to itself based on the values of top, right, bottom, and left. The offset does not affect the position of any other elements; thus, the space given for the element in the page layout is the same as if position were static. This value creates a new stacking context when the value of z-index is not auto. Its effect on table-*-group, table-row, table-column, table-cell, and table-caption elements is undefined.
Absolute The element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to its closest positioned ancestor, if any; otherwise, it is placed relative to the initial containing block. Its final position is determined by the values of top, right, bottom, and left. This value creates a new stacking context when the value of z-index is not auto. The margins of absolutely positioned boxes do not collapse with other margins.
Fixed The element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to the initial containing block established by the viewport, except when one of its ancestors has a transform, perspective, or filter property set to something other than none (see the CSS Transforms Spec), in which case that ancestor behaves as the containing block. (Note that there are browser inconsistencies with perspective and filter contributing to containing block formation.) Its final position is determined by the values of top, right, bottom, and left. This value always creates a new stacking context.In printed documents, the element is placed in the same position on every page.
Sticky The element is positioned according to the normal flow of the document, and then offset relative to its nearest scrolling ancestor and containing block (nearest block-level ancestor), including table-related elements, based on the values of top, right, bottom, and left. The offset does not affect the position of any other elements. This value always creates a new stacking context.Note that a sticky element "sticks" to its nearest ancestor that has a "scrolling mechanism" (created when overflow is hidden, scroll, auto, or overlay), even if that ancestor isn't the nearest actually scrolling ancestor. This effectively inhibits any "sticky" behavior (see the GitHub issue on W3C CSSWG).

StreamType Enum

Value Description
HTMLFormat = 4 HTML format (Hypertext Markup Language).
RichTextFormat = 8 RTF format (Rich Text Format).
PlainText = 16 Text in Windows Unicode format (an end of a paragraph is marked with the control characters 13 and 10).
InternalUnicodeFormat = 32 Text Control format. Text is stored in Unicode format.
MSWord = 64 Microsoft Word format (.DOC version).
XMLFormat = 128 XML format (Extensible Markup Language).
AdobePDF = 512 Adobe Portable Document Format (PDF). If a document is loaded, only the text is imported.
WordprocessingML = 1024 Microsoft Word format (Office Open XML version).
SpreadsheetML = 4096 Microsoft Excel format (Office Open XML version).

OAuthSettings Object

Property Value Type Description
ClientId string Gets or sets the OAuth client ID.
ClientSecret string Gets or sets the OAuth client secret.
RedirectUri string Gets or sets the OAuth redirect URI.

API Reference

The DocumentEditor provides a fully-featured JavaScript API that gives access to all document elements to manipulate documents programmatically. The JavaScript API is separately explained in the Reference Guide:

JavaScript API - TXTextControl Object

DocumentViewer

This library provides a document viewer to render documents in any browser including Google Chrome, Firefox, Safari and Edge.

Installation

Install-Package TXTextControl.DocumentServices.DocumentViewer

Usage

The library implements an HTML Helper for MVC Razor applications. The following sample code shows how to add the viewer to an MVC view:

@using TXTextControl.DocumentServices.DocumentViewer;

@await Html.TXTextControl().DocumentViewer(s => {
    s.DocumentData = "SGVsbG8gdGhlcmU=";
    s.Dock = DocumentViewerSettings.DockStyle.Window;
    s.IsSelectionActivated = true;
    s.ShowThumbnailPane = true;
    s.BasePath = "https://yourdomain.com/DocumentServices";
    s.OAuthSettings.ClientId = "dsserver.ZVOL4OPU664IqA0NMJAisrX2iCeLaOmo";
    s.OAuthSettings.ClientSecret = "faZwTMHRe0VgKfyvMgD8FM8eOKymEst3";
    s.OAuthSettings.RedirectUri = "https://yourdomain.com/DocumentEditor/textcontrol/DocumentEditor/auth/callback";
}).RenderAsync()

Trial Token

If you are evaluating DS Server and you are using a trial token, remove the third parameter in the OAuthSettings (RedirectUri) and replace the BasePath with the demo server location https://trial.dsserver.io.


@using TXTextControl.DocumentServices.DocumentViewer;

@await Html.TXTextControl().DocumentViewer(s => {
    s.DocumentData = "SGVsbG8gdGhlcmU=";
    s.Dock = DocumentViewerSettings.DockStyle.Window;
    s.IsSelectionActivated = true;
    s.ShowThumbnailPane = true;
    s.BasePath = "https://trial.dsserver.io";
    s.OAuthSettings.ClientId = "dsserver.ZVOL4OPU664IqA0NMJAisrX2iCeLaOmo";
    s.OAuthSettings.ClientSecret = "faZwTMHRe0VgKfyvMgD8FM8eOKymEst3";
}).RenderAsync()

Available Properties

Property Value Type Description
DocumentData byte[] Specifies the document data from where to load the document to edit. For text based document file formats (e. g. HTML or RTF) this must be utf-8 data.
OAuthSettings OAuthSettings Specifies the OAuth settings.
UserNames string[] Gets or sets the available user names.
BasePath string Gets or sets the service URL.
ResourceManager ResourceManager Gets or sets the resource manager.
ToolbarDocked bool Specifies whether the toolbar is docked or not.
DocumentPath string Gets or sets the document path from where to load the document. If DocumentData is defined, this string is used as the document name rendered in the status bar.
IsSelectionActivated bool Specifies whether the selection feature is active or not.
SignatureSettings SignatureSettings Specifies the signature settings.
ShowThumbnailPane bool Specifies whether the thumbnail view pane is visible by default.
Dock DockStyle Specifies how to dock the DocumentViewer.

Custom Objects

SignatureSettings Object

Property Value Type Description
OwnerName string Specifies the name of the document owner.
SignatureBoxName string Specifies the name of the signature boxes to sign.
SignerName string Specifies the name of the signer.
SignerInitials string Specifies the initials of the signer.
ShowSignatureBar bool Specifies whether the signature bar is active or not.
UniqueId string Gets or sets a unique document envelope Id.
RedirectUrlAfterSignature string Gets or sets an Url that is used for redirection after a successful signing process.

OAuthSettings Object

Property Value Type Description
ClientId string Gets or sets the OAuth client ID.
ClientSecret string Gets or sets the OAuth client secret.
RedirectUri string Gets or sets the OAuth redirect URI.

DockStyle Enum

Property Description
Window Fills the complete browser Window and is on top of other elements.
Fill Fills the container with width and height equals 100%.

API Reference

The DocumentViewer provides a JavaScript API to programmatically access functionality of the viewer component. The JavaScript API is separately explained in the Reference Guide:

JavaScript API - TXDocumentViewer Object

DocumentProcessing

This library provides a fully-featured SDK to access the DocumentProcessing Web API of DS Server.

Installation

Install-Package TXTextControl.DocumentServices.DocumentProcessing

Usage

The library provides a non-UI class library to manipulate documents. The following example creates thumbnail images from a given RTF document.

private static readonly DocumentProcessing s_dp;

var os = new OAuthSettings(
    "dsserver.ZVOL4OPU664IqA0NMJAisrX2iCeLaOmo",
    "faZwTMHRe0VgKfyvMgD8FM8eOKymEst3",
    "https://yourdomain.com/DocumentEditor/textcontrol/DocumentEditor/auth/callback");

s_dp = new DocumentProcessing("https://yourdomain.com/DocumentServices", os);

string rootPath = env.ContentRootPath;
string docFilePath = Path.Combine(rootPath, "App_Data/Demo.rtf");
m_strDemoRtf = System.IO.File.ReadAllText(docFilePath, Encoding.ASCII);
m_demoRtfUtf8 = Encoding.UTF8.GetBytes(m_strDemoRtf);

var thumbnails = await s_dp.Thumbnails(m_demoRtfUtf8, 50);

Trial Token

If you are evaluating DS Server and you are using a trial token, remove the third parameter in the OAuthSettings (RedirectUri) and replace the ServiceUrl with the demo server location https://trial.dsserver.io.


private static readonly DocumentProcessing s_dp;

var os = new OAuthSettings(
    "dsserver.ZVOL4OPU664IqA0NMJAisrX2iCeLaOmo",
    "faZwTMHRe0VgKfyvMgD8FM8eOKymEst3");

s_dp = new DocumentProcessing("https://trial.dsserver.io", os);

string rootPath = env.ContentRootPath;
string docFilePath = Path.Combine(rootPath, "App_Data/Demo.rtf");
m_strDemoRtf = System.IO.File.ReadAllText(docFilePath, Encoding.ASCII);
m_demoRtfUtf8 = Encoding.UTF8.GetBytes(m_strDemoRtf);

var thumbnails = await s_dp.Thumbnails(m_demoRtfUtf8, 50);

API Reference

The API is separately described in the Reference Guide.