Some test text!

Supporting XRefskeyboard_arrow_down

Supporting XRefs

linkSupporting XRefs

XRefs (external references) are used within CAD documents to reference external documents to be loaded within a main document. WebViewer Server by default does not support these XRefs as it needs to know context information about the location of the XRef files.

We do provide an option TRN_CAD_XREF_CONFIG_URL that will allow you to provide this context information, but there are a few steps that will need to be done in order to use this option.

To use this option, you will need to do the following.

  1. Determine a way to match XRefs to a document.
  2. Create a server which will, given a request with a document, return the correct XRefs.
  3. Add the XRef files to an accessible file location on WebViewer Server.
  4. Set TRN_CAD_XREF_CONFIG_URL to the created server.

linkDetermine a way to match XRefs to a document

The most common way is by providing a header during the load document call, and then matching this header to the correct XRefs.

  .then(instance => {
    const options = {
      customHeaders: { MyDocIdentifier: "12345id" },
      filename: "Document.pdf"
    const url = 'http://<documentserver>/mydocument.pdf'
    instance.loadDocument(url, options);

Now the server will see MyDocIdentifier when WebViewer Server requests it, it can then return the XRef paths for this document like so:

XRefSearchPaths: ['mypath/mpath/path', 'mypath2/path/path']

WebViewer Server would then look in these paths for XRefs.

linkCreate a server to return the XRefs

In the next step you will need to create a server that will do the following:

  1. Accept a GET request
  2. Read the a header from the request
  3. Return XRefs based on this header in JSON format

Paths returned by the server should have the following traits

  • They should be absolute paths
  • They should point to the folder containing the external files
  • The path should only be a local system path

The code below is a rough example of how you would do this. The specifics of how you implement XRef path selection will be specific to your system.

from http.server import BaseHTTPRequestHandler,HTTPServer
import json

xrefPaths = { 
'docId1' : ['/path/path1/path', '/path/path2'], 
'docId2' : ['/path3/path']

class Server(BaseHTTPRequestHandler):
    def _set_headers(self):
        self.send_header('Content-type', 'application/json')

    def do_HEAD(self):

    def do_GET(self):
        # here you would get each individual XRef path based on the ID
        # and return them in JSON below
        myId = self.headers["MyDocIdentifier"]
        myPaths = xrefPaths[myId]
        self.wfile.write(json.dumps({'XRefSearchPaths': myPaths }).encode())

def run(server_class=HTTPServer, handler_class=Server, port=8008):
    server_address = ('', port)
    httpd = server_class(server_address, handler_class)

    print('Starting httpd on port %d...' % port)

if __name__ == "__main__":

linkAdd the XRefs to the server

Using Docker

In docker you should mount volumes at the specific XRef paths like so:


You would then set XRefs to be looked for inside of this xrefFiles directory.

Using Windows

On windows, you only need to provide the correct paths and your XRefs should be found.


A prerequiste to this step would be to setup your server over a local network or the internet to be accessible by WebViewer Server. In this example, the server is hosted on under the path getXrefs:


If everything was done correctly, XRefs should now be appearing in your documents.

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.