URL to the Support API service that will be used to enable PDF editing features.
Specifies a custom implementation of the SupportApi for editing functions. When this property is set, the viewer will use the provided custom implementation instead of a separate service. All other properties (apiUrl, webSocketUrl, and token) will be ignored.
// Example
var viewer = new DsPdfViewer("#root", {
supportApi: {
implementation: new CustomSupportApi()
}
});
Optional
legacySet this setting to true if you are using the Web Forms (WEB API 2) version of the SupportApi service. Note, in most cases, you do not need to set this setting, the server type is determined by the viewer automatically.
const viewer = new DsPdfViewer("#viewer", {
supportApi: {
apiUrl: "/api/pdf-viewer",
webSocketUrl: "/signalr",
legacyServer: true,
token: "support-api-demo-net-core-token"
}
});
Optional
reconnectAutomatically reconnect to the server at the specified interval in milliseconds. Used by persistent connections.
5000
Optional
requestThe internal Support API client uses the fetch API to make requests to the server. Use the requestInit setting to configure fetch options (like authorization headers, etc), see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch for details.
// Include Basic Authentication headers:
const viewer = new DsPdfViewer("#viewer", {
supportApi: {
apiUrl: "192.168.0.1/support-api",
requestInit: {
headers: {
"Authorization": "Basic " + btoa(unescape(encodeURIComponent("USERNAME:PASSWORD"))),
"CustomHeader": "Custom header value"
}
}
}
});
Optional
suppressSuppress Support API error messages (e.g. messages about the Support API availability / version mismatch).
// Suppress both error and informational messages:
const viewer = new DsPdfViewer("#viewer", {
supportApi: {
apiUrl: "http://192.168.0.1/support-api",
webSocketUrl: false,
suppressInfoMessages: true,
suppressErrorMessages: true
}
});
Optional
suppressSuppress Support API informational messages (e.g. Support API reconnect messages).
// Suppress informational messages only:
const viewer = new DsPdfViewer("#viewer", {
supportApi: {
apiUrl: "http://192.168.0.1/support-api",
webSocketUrl: false,
suppressInfoMessages: true
}
});
Optional
token?: stringAuthentication or antiforgery token. In each subsequent SupportApi request, the token is passed in the request for server-side validation. You can use ASP.NET Core Antiforgery to generate and verify security token, see Cross-Site Request Forgery (XSRF/CSRF) attacks in ASP.NET Core for details.
// Specify antiforgery token on client side:
const viewer = new DsPdfViewer("#viewer", {
supportApi: {
apiUrl: "192.168.0.1/support-api",
token: "support-api-demo-net-core-token",
webSocketUrl: false
}
});
// Here is an example of how to validate the token on the server side inside the SupportApi service project:
// Startup.cs:
GcPdfViewerController.Settings.VerifyToken += VerifyAuthToken;
private void VerifyAuthToken(object sender, SupportApi.Models.VerifyTokenEventArgs e)
{
string token = e.Token;
if (token != "support-api-demo-net-core-token")
{
e.Reject = true;
}
}
Optional
webOptional. SignalR socket URL for persistent connections. Persistent connections are required for collaboration mode. Set this setting to false to disable persistent connections.
/signalr
Settings for configuring the Support API in the viewer.