xtrareports-401546-web-reporting-knockout-reporting-document-viewer-document-viewer-integration-with-npm-yarn.md
You can use the HTML5 Document Viewer in a JavaScript application. You should create two projects:
You can use DevExpress CLI Templates to create an ASP.NET Core back-end application. Begin with the steps below:
Install DevExpress ASP.NET Core project templates from nuget.org:
Create a back-end Reporting application for a Document Viewer:
Enable cross-origin requests (CORS). Specify the policy that allows any local application to access the report’s back-end. Use the SetIsOriginAllowed method to set it up.
To run the server-side application, run the following command:
To create a back-end application from a Microsoft or DevExpress Template in Visual Studio, review the following help topics:
The following steps configure and host the client part:
Create a new folder to store the client-side files (ClientSide in this example).
Create a package.json file in the ClientSide folder with the following content:
Ensure that you have npm or Yarn package managers installed.
Navigate to the client application root folder (ClientSide) and run the command in the command prompt:
Create an index.html file. It is the View file in our model. Copy the following HTML code and insert it in this file:
Create a example.js file to provide data to the View. The JavaScript code in this file creates a viewerOptions variable. Copy the following code and insert it in the example.js file:
Modify the index.html file to specify the HTML template that uses the Document Viewer’s binding with the viewerOptions parameter. Add the following code to the body section:
Host the client-side part on the web server. Start the Internet Information Services (IIS) Manager, right-click the Sites item in the Connections section, and select Add Website. In the invoked dialog, specify the site name, path to the client-side application root folder, and the website’s IP address and port.
Run the backend project.
Open the website created in step 8, in the browser. In this example, the address is http://localhost:1000.
You may encounter the following problems:
The Document Viewer page is blank. The following error message is displayed at the bottom of the page:
Could not open report ‘TestReport’
Check the following:
host setting of the Document Viewer component.reportUrl setting value matches an existing report. For the backend application, ensure that either the Reports folder contains a reportUrl.repx file or the ReportsFactory.Reports dictionary contains the reportUrl entry (if the back-end application originated from the DevExpress template).Refer to the following topic for more information: Troubleshooting.