July 13, 2021

DWF AND PDF SUPPORT IN FORGE VIEWER

The Forge Viewer (7.36) makes it easy to load and view PDF and DWF files natively. In the past these files had to be processed using the Model Derivative service but now you can use viewer extensions called Autodesk.DWF and Autodesk.PDF to load these file formats natively, similar to the Autodesk.glTF extension (https://forge.autodesk.com/blog/gltf-20-support-forge-viewer). All you need to do is call the loadExtension and loadModel methods according to your specific file type.

Example for DWF file

Autodesk.Viewing.Initializer({ env: 'Local' }, async function () {

    const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('preview'));

    viewer.start();

    viewer.setTheme('light-theme');

    viewer.loadExtension('Autodesk.DWF').then(() => {

        viewer.loadModel('/VizProject3d.DWF');

    });

})

Example for PDF file

Autodesk.Viewing.Initializer({ env: 'Local' }, async function () {

    const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('preview'));

    viewer.start();

    viewer.setTheme('light-theme');

    viewer.loadExtension('Autodesk.PDF').then(() => {

        viewer.loadModel('/ visualization_-_aerial.pdf');

    });

});

 

For a complete example, see the main.js file in the https://github.com/petrbroz/forge-basic-app/tree/experiment/pdf repository.

If you have any questions, please contact the Forge Support team.

Posted by

Deepali Srivastava

Developer Consultant

Deepali Srivastava is a developer consultant at Autodesk. She helps in programming and API calling support. She started her career in and is based out of Bengaluru, India.

Developer Advocate, Autodesk

Petr is a senior developer advocate at Autodesk. He has been developing some of the company’s web applications and services since 2011, and now he aims to help others build amazing, creative solutions using these tools, especially using Autodesk Forge APIs. Petr’s technical focus areas include everything around web and cloud, 3D graphics, and all kinds of "non-real reality".

Developer Advocate, Autodesk

Developer Advocate at Autodesk since 2008, working with both desktop and web/cloud apps using top technologies, like C#, JavaScript, NodeJS and any other that can solve problems and improve workflows. See my samples on Github and follow me on Twitter for updates. 

Related Posts