DocuVieware Reference Guide
Integrating DocuVieware in your Node.js client application
Tutorials > Other Web Technologies using REST > Node.js > Integrating DocuVieware in your Node.js client application
The purpose of this tutorial is to highlight the integration of the DocuVieware control into a client application, so please first be sure to follow the Serving DocuVieware through a REST API tutorial.
The source code of both REST service implementation and integration are available in your [INSTALL FOLDER]\Samples\ASP.NET\DocuVieware\ folder.
 Prerequisite

DocuVieware™ only requires its own resources, one JavaScript file and one CSS file, both can be found in your [SDK INSTALL DIR]\Redist\DocuVieware (Resources)\ folder. In the following examples, it will be assumed that they are available locally.

<script src="docuvieware-min.js"></script>
<link rel="stylesheet" type="text/css" href="docuvieware-min.css">

The last thing required is the complete and accurate URL your REST service is reachable at.

For this tutorial it is assumed that the service is locally running on the machine using the port 62968. The complete URL to the method is http://localhost:62968/api/DocuViewareREST/GetDocuViewareControl.
Be careful: your own implementation will most probably differ, especially the port that is usually randomly selected upon project creation by Visual Studio so be sure to adapt the URL to your configuration.

 Integration using Node.js
var http = require("http");
var docuViewareConfiguration = JSON.stringify({
    "SessionId": "mySessionId", //Set to an arbitrary value, should be replaced by the session identifier from your session mechanism
    "ControlId": "DocuVieware1",
    "AllowPrint": true,
    "EnablePrintButton": true,
    "AllowUpload": true,
    "EnableFileUploadButton": true,
    "CollapsedSnapIn": true,
    "ShowAnnotationsSnapIn": true,
    "EnableRotateButtons": true,
    "EnableZoomButtons": true,
    "EnablePageViewButtons": true,
    "EnableMultipleThumbnailSelection": true,
    "EnableMouseModeButtons": true,
    "EnableFormFieldsEdition": true,
    "EnableTwainAcquisitionButton": true
});
var postheaders = {
    "Content-Type": "application/json",
    "Content-Length": Buffer.byteLength(docuViewareConfiguration, "utf8")
};
var optionspost = {
    host: "localhost",
    port: 62968,
    path: "/api/DocuViewareREST/GetDocuViewareControl",
    method: "POST",
    headers: postheaders
};
var reqPost = http.request(optionspost, function (res) {
    res.on("data", function (data) {
        console.log(data.toString());
    });
});
reqPost.write(docuViewareConfiguration);
reqPost.end();
reqPost.on("error", function (e) {
    console.error(e);
});
See Also