October 4, 2018

Showing PDF files in the 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 Posts

June 5, 2019

What icons are provided by the Viewer stylesheet

At the Forge Accelerator in Boston Tianmin asked if there was an easy way to see

Read More