This is a sample application that uses the Fluent JavaScript RESTful Client to generate a document and displays the result with Apryse WebViewer. This application, when started will allow you to navigate to the webpage, click the "Generate Document" button and will then show the output in the WebViewer window. The WebViewer window will initially be populated with the sample template.
There are 3 main files to worry about:
- server.ts
- This file is the Node.js server file that also contains the document generation logic
- index.html
- This file contains the code for the webpage as well as initializing and using Apryse WebViewer
- config.json
- This file contains the config options to specify your license keys, your RESTful Engine instance to be used by the application as well as the properties for which template you would like to generate output for.
- Make sure you have Node.js installed on your machine (which includes npm).
- You need a running instance of the Fluent RESTful Engine.
- (Optional) WebViewer License Key. To get a trial key you can go here.
- If you don't specify a license, a watermark will be present on output, but it is still fully usable
- (Optional) Fluent Engine Key. To get a trial key you can go here.
- If you don't specify a license, a watermark will be present on output, but it is still fully usable
- Open the
config.jsonfile and insert your RESTful Engine URL (This is required)- You can insert your Fluent and WebViewer license keys as well but this isn't required to use the sample.
- Open a terminal and navigate to the root of this project
- Run the command
npm installto install the required packages - Run the command
npm run buildto build the project - Run the command
npm startto start the project. This should start the server athttp://localhost:3000. - Open your browser and navigate to
http://localhost:3000to start using the sample app.
template-connection-string: This is the property where you will place the remote url or filepath for the template you would like to generate output for.- It is strongly recommended that if you are using local files, to place them in the
filesdirectory and reference the file using relative paths. This allows Webviewer to display the template when the application starts
- It is strongly recommended that if you are using local files, to place them in the
output-format: This is the output format for the document that will be generated. Valid options aredocx/xlsx/pptx(must match your template format)pdfhtml
datasources: This is a list of datasources that are required for your template. Each datasource takes 3 values:name: The user-given name of the datasource used in the templatetype: The type of datasource it is. Valid datasource types are:xml: The legacy xml datasourcexml2: The modern (saxon) xml datasourcejson: A json file datasourcesql: A SQL datasource
connection-string: This is the connection string for the datasource. This can be a url/path to a file, or a jdbc formatted connection string for SQL.
input-parameters: This is a list of input parameters needed for the template. Each input parameter takes 3 values:name: The name of the input parametertype: The type of the input parameter. Valid types are:string: A text based valueboolean: A true/false valuedatetime: A date/time based valuenumber: A number value (doesn't include decimals)decimal: A number value that includes decimals
value: The value fo the input parameter to use during output generation