4 Oct 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 Article

Posted By

Adam Nagy

Follow @AdamTheNagy Adam Nagy joined Autodesk back in 2005 and has been providing programming support, consulting, training and evangelism to external developers. He started his career in Budapest, then worked in Prague for 3 years and now lives in South England, UK. At the moment focusing on Inventor and Fusion 360, plus cloud and mobile related technologies. Adam has a degree in Software Engineering and has...