13 Jul 2021
DWF Local Support in APS 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.