CADViewer Technical Documentation, Installation Guide and Reference Samples Library

NodeJS

This documents running a standard CADViewer top-level JavaScript instance with the NodeJS conversion server in the same folder tree.

The NodeJS backend server: https://github.com/CADViewer/cadviewer-conversion-server, are typically the primary Back-end installation when installing CADViewer on ReactJS, Angular and VueJS.

Folder Structure

For a CADViewer NodeJS installation on Windows, the base file-structure should be as below:

windows:
c:/nodejs
linux:
/usr/bin/

    └─── cadviewer-conversion-server
            ├── app
            │    ├── cv
            │    │    ├── cv-pro 
            │    │    │   ├── menu_config
            │    │    │   └── language_table
            │    │    ├── cv-core
            │    │    │   ├── menu_config
            │    │    │   └── language_table
            │    │    └── cv-custom_commands
            │    ├── js
            │    └── css
            ├── converters
            │    ├── ax2022
            │    │     ├── windows 
            │    │     │      └── fonts
            │    │     └── linux
            │    │            └── fonts
            │    ├── dwgmerge2022
            │    │         ├── windows 
            │    │         │      └── fonts
            │    │         └── linux
            │    │            └── fonts
            │    ├── linklist2020
            │    │         ├── windows 
            │    │         │     └── fonts
            │    │         └── linux
            │    │               └── fonts
            │    └── files
            ├── content
            ├── html
            └── temp_print

Note that folders for advanced interaction, such as database connectivity and advanced REST-API connectivity features are not included in this folder tree, please see the Samples section for integration with this type of functionality.

Configuration

In folder:

windows:
c:/nodejs
linux:
/usr/bin/

c:/nodejs
    └─── cadviewer

locate the configuration file: CADViewer_config.json , edit the settings to reflect your installation. Note that, in this setup is assuming the front-end server with the CADViewer html file to have the ServerFrontEndUrl and the conversion server to have the ServerUrl settings.

There are a number of template CADViewer_config_xxx.json files with the most common settings on various platforms. Please use as your template.

This is the configuration file for a ReactJS front-end with NodeJS back-end on Windows:

{
    "ServerPort" : 3000,
    "ServerUrl" : "http://localhost:3000",
    "ServerFrontEndUrl" : "http://localhost:8000",
    "ServerLocation" : "c:/nodejs/cadviewer-conversion-server/",
    "fileLocation" : "c:/nodejs/cadviewer-conversion-server/converters/files/",
    "fileLocationUrl" : "http://127.0.0.1:3000/converters/files/",
    "converterLocation" : "c:/nodejs/cadviewer-conversion-server/converters/ax2022/windows/",
    "fontLocation" : "c:/nodejs/cadviewer-conversion-server/converters/ax2022/windows/fonts/",
    "ax2020_executable" : "AX2022_W64_22_12_67.exe",
    "cvjs_svgz_compress" : true,
    "licenseLocation" : "c:/nodejs/cadviewer-conversion-server/converters/ax2022/windows/",
    "xpathLocation" : "c:/nodejs/cadviewer-conversion-server/converters/xpath/",
    "callbackMethod" : "getcadviewercontent",
    "cvjs_debug" : true,
    "temp_print_folder" : "C:/nodejs/cadviewer-conversion-server/temp_print",
	"dwgmergeLocation" : "c:/nodejs/cadviewer-conversion-server/converters/dwgmerge2020/windows/",
	"dwgmerge2020_executable" : "DwgMerge2020.exe",
	"linklistLocation" : "c:/nodejs/cadviewer-conversion-server/converters/linklist2022/windows/",
	"linklist2020_executable" : "LinkList_2022_W32_22_07_15.exe"
}	

Front-end Initalization

For the combination of ReactJS front-end and NodeJS back-end a typical Handler initialization looks like:

		// Standard NodeJS Server
		var ServerBackEndUrl = "http://localhost:3000/";
		var ServerLocation = "";    // leave blank

		// Standard Front-end
		var ServerUrl = "http://localhost:8000/";

		// Set all paths, and handlers, changes these depending on back-end server
		cadviewer.cvjs_setAllServerPaths_and_Handlers(ServerBackEndUrl, ServerUrl, ServerLocation, "NodeJS", "ReactJS", "floorPlan");

See the API documentation for initialization:


Run Server

Run the Back-End server from the location of the installation:

C:\nodejs\cadviewer>node CV_6.X.YY.js
Version: CADViewer Server v6.8.65
ServerUrl: http://localhost:3000
ServerFrontEndUrl: http://localhost:8000
ServerLocation: c:/nodejs/cadviewer-conversion-server/
Callback: getcadviewercontent
svgz_compress: true
debug: true
AX converter: AX2022_W64_22_12_67.exe
LInkList converter: LinkList_2022_W32_22_07_15.exe
CADViewer Server is listening on port:3000!

Use one of our reference sample as front-end, please see all our GitHub Repositories, specifically use the ReactJS Sample.

Use the server traces and browser development console for debugging, alternatively contact our Support

Troubleshooting

One issue that often appears in installations is that interface icons do not display properly:

Icons

Typically the variable ServerUrl or ServerBackEndUrl is not set to reflect the front-end server url or port.



Server Source Code

The NodeJS server code is similar on Windows and Linux, the latest version is CV_6.X.YY.js .

Application programmers may modify content to integrate with their own software or application.

Use the following Github link: https://github.com/CADViewer/cadviewer-conversion-server

Last updated on 10 Mar 2022
Published on 13 Mar 2020