CADViewer Technical Documentation, Installation Guide and Reference Samples Library

PHP

Folder Structure

For a CADViewer PHP installation, the base file-structure should be as below:

windows:
   c:\xampp\htdocs
linux:
   /var/www/html/

       └─── cadviewer
               ├── app
               │    ├── cv
               │    │    ├── cv-pro 
               │    │    │   ├── menu_config
               │    │    │   ├── language_table
               │    │    │   └── space
               │    │    │         ├── css 
               │    │    │         └── html
               │    │    ├── cv-core
               │    │    │   ├── menu_config
               │    │    │   └── language_table
               │    │    └── cv-custom_commands
               │    ├── fonts
               │    ├── images
               │    ├── js
               │    ├── css
               │    └── user_resources	
               ├── converters
               │    ├── ax2022
               │    │     ├── windows 
               │    │     │      └── fonts
               │    │     └── linux
               │    │            └── fonts
               │    ├── dwgmerge2022
               │    │         ├── windows 
               │    │         │      └── fonts
               │    │         └── linux
               │    │            └── fonts
               │    ├── linklist2022
               │    │         ├── windows 
               │    │         │     └── fonts
               │    │         └── linux
               │    │               └── fonts
               │    └── files
               ├── php
               ├── 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.

PHP Configuration

In folder:

windows:
   c:\xampp\htdocs
linux:
   /var/www/html/

       └─── cadviewer
               └── php

locate the configuration file: CADViewer_config.php , edit the settings to reflect your installation. Editing the variables $httpHost and $home_dir is typically sufficient. Also, note that the paths for the converter location, license location and font path locations differs on Windows and Linux, so uncomment/hide those values according to your platform.

<?php
//  New: Use this code to find $httpHost and $home_dir based on current location, if under /cadviewer/
	$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
	$pos1 = stripos($actual_link, "/cadviewer/");
	$httpHost = substr($actual_link, 0, $pos1+ 11);

	$currentpath = __FILE__;
	$pos1 = stripos($currentpath, "cadviewer");
	$home_dir = substr($currentpath, 0, $pos1+ 10);

//  Http Host   - note use direct setting if path different from /cadviewer/. 
//  URL to the location of home directory the converter infrastructure
//	$httpHost = "http://localhost/cadviewer";

//  Home directory, the local path corresponding to the http host - note use direct setting if path different from cadviewer. 
//  Windows
//	$home_dir = "/xampp/htdocs/cadviewer";
//  Linux
//	$home_dir = "/var/www/html/cadviewer";

//MOST PATHS ARE SET UP BASED ON HttpHost and home_dir    (Users can change this setting if an implementation needs to split up locations)
// NEW  we make an $home_dir_app  to give the user the ability to freely move $fileLocation + $converterLocation away from web-structure
	$home_dir_app = $home_dir;

// set the platform for /converter subfolder
	$platform = "windows";
//	$platform = "linux";
	
//  Conversion engines executables - names stays stable with each upgrade of conversion engines:
// 	Linux
//	$ax2020_executable = "ax2022_L64_22_12_65b";
// 	Windows
	$ax2020_executable = "AX2022_W64_22_12_65.exe";

//  USE svgz compression
	$svgz_compress = false;   // default is false

//  DwgMerge engines executables - names stays stable with each upgrade of conversion engines:
// 	Linux
//	$dwgmerge2020_executable = "DwgMerge_W32_19_01_02";
// 	Windows
	$dwgmerge2020_executable = "DwgMerge_W32_20_02_00b.exe";

//  DwgMerge engines executables - names stays stable with each upgrade of conversion engines:
// 	Linux
//	$linklist2022_executable = "DwgMerge_W32_20_01_05.exe";
// 	Windows
	$linklist2022_executable = "LinkList_2022_W32_22_07_15.exe";
// ........
// .........

HTML

In folder:

windows:
   c:\xampp\htdocs
linux:
   /var/www/html/

      └─── cadviewer
            └── html

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

    var ServerBackEndUrl = window.location.protocol+"//"+window.location.hostname+"/cadviewer/";
    var ServerUrl = window.location.protocol+"//"+window.location.hostname+"/cadviewer/";
    var ServerLocation = "";

	// Pass over the location of the installation, will update the internal paths
	cvjs_setAllServerPaths_and_Handlers(ServerBackEndUrl, ServerUrl, ServerLocation, "PHP", "JavaScript", "floorPlan");

See the API documentation for initialization:


Running

Open a web-browser pointing to your sample html file: http:/localhost/cadviewer/html/mysample.html , where *mysample.html is one of the html files in the folder /cadviewer/html.

Debugging

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

For debugging, the folder:

windows:
   c:\xampp\htdocs
linux:
   /var/www/html/

         └─── cadviewer
               └── php

contains a debug file call-Api_Conversion_log.txt that lists the command line and traces in the communication with the back-end converter AutoXchange 2022. If drawing files does not display, this file will contain useful information to pinpoint the issue.

Troubleshooting

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

Icons

Typically the variable ServerUrl in /cadviewer/app/cv/CADViewer_PHPHandlerSettings.js is not set to reflect the front-end server url or port.

Last updated on 25 Feb 2022
Published on 13 Mar 2020