0
votes

I am struggling to view a pdf in the forge viewer. All other drawings .rvt .dwg .dxf .nwd are showing without any issue.

Initially I received a error

Cannot read property 'loadFromZip' of undefined

Have managed to evade this by adding "loadOptions" into the modeloptions I send through to the viewer. But now I get a error 6 back from the viewer which is a server error. Please if someone could advise what to do.

loadModel() {
    var initialViewable = viewables[indexViewable];
    var svfUrl = lmvDoc.getViewablePath(initialViewable);
    var modelOptions = {
        sharedPropertyDbPath: lmvDoc.getPropertyDbPath(),
        loadOptions: {}
    };
    viewer.loadModel(
        svfUrl,
        modelOptions,
        this.onLoadModelSuccess,
        this.onLoadModelError
    );
}

Thanks in advance

1

1 Answers

0
votes

You have to use ViewingApplication rather than Viewer3D or GuiViewer3D to initialize your viewer to view PDF files since there are some additional configuration values for PDF set up by the ViewingApplication automatically.

Also refer to: Forge Viewer fails to dispaly PDF's

=== Example for passing configs to Viewer instance via ViewingApplication ===

//--- Method 1:
var viewerConfigs = {
    extensions: ['MyAwesomeExtension'],
    extOpts: {
        MyAwesomeExtension: {
             buttonColor: 'red'
        }
    }
};
var viewerApp = new Autodesk.Viewing.ViewingApplication('MyViewerDiv');
viewerApp.registerViewer(viewerApp.k3D, Autodesk.Viewing.Private.GuiViewer3D, viewerConfigs);

// In the constructor of the MyAwesomeExtension
class MyAwesomeExtension extends Autodesk.Viewing.Extension {
  constructor( viewer, options ) {
    super( viewer, options );

    // your options here
    const opts = options.extOpts.MyAwesomeExtension;
  }
}

//--- Method 2:
// After model was loadded,
var viewer = viewerApp.getCurrentViewer();
var extOpts = {
   opt1: true
};
viewer.loadExtension( 'Autodesk.ADN.MyExtension', extOpts );

For more details, please refer: