4 Oct 2018

Showing PDF files in the Viewer

Viewer

This is how my code used to load 2D models:

geometryItems = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), {
    'type': 'geometry',
    'role': '2d'
}, true);

if (geometryItems.length > 0) {
    var path = doc.getViewablePath(geometryItems[0]);
    var options = {};
    viewer.loadModel(path, options);
}

However, this throws an error that the relevant resources could not be found when trying to load a PDF document.

Now there is a new function to load your models which will also take care of loading PDF files, called loadDocumentNode()

Here is the updated code that works :)

if (geometryItems.length > 0) {
    viewer.loadDocumentNode(doc, geometryItems[0]);
}

 

Related Article