Autodesk PDF Forge viewer error while rendering document

Viewed 264

I am receiving following error (see image) while trying to load PDF file into Autodesk forge viewer.

Warning: getOperatorList - ignoring errors during "GetOperatorList: page 0" task: "t: Cannot read property 'X' of undefined". pdf.worker.js:1772

We are using JS 10.16.0 64bit version.

Can someone please help how to fix this?

Thank you Jignesh

enter image description here

2 Answers

I'm not sure to understand what you are doing ...

Autodesk Forge supports PDF so the easiest way to display PDF in the Forge viewer is to upload your PDF using the DataManagement API, translate it into SVF with the ModelDerivative API and you will be able to load it into the viewer.

If you are new to Forge, you can follow this guide : https://forge.autodesk.com/developer/learn/viewer-app/overview

I am using following code and PDF file is not displayed in the viewer

//----------------------------------------------------------------------------------------
// Initialize options for PDF viewer.
// Input: pdf - link for PDF file
//----------------------------------------------------------------------------------------
initializeViewer( pdf ) {
    var options = {
            env: "Local",
            useADP: false,
            method: "POST"
    }
    //----------------------------------------------------------------------------------------
    // Initialize PDF viewer and load PDF document into the viewer
    // Input: PDF - link for PDF file
    //----------------------------------------------------------------------------------------
    Autodesk.Viewing.Initializer(options, () => {
        this.pdfViewer = new Autodesk.Viewing.Private.GuiViewer3D(this._container), {disabledExtensions:{hyperlink:true}};
        if (!pdf)
        {
            //viewer.unload();
            return;
        }

        // add even listener function to remove un-wanted extensions
        this.pdfViewer.addEventListener(
            Autodesk.Viewing.EXTENSION_LOADED_EVENT,
            this.onExtensionLoaded);

            this.pdfViewer.setTheme("light-theme");
            this.pdfViewer.start(pdf, options);
        //const localFilePath = './pdf/';
        //const localFilePath = './na.bvcorp.net/Data/apps/POWRTRAK/DMT/DMT_KANSASCITY_DEV/T400425/MK-00001/'

        this.pdfViewer.loadExtension('Autodesk.PDF').then( () => {
            this.pdfViewer.loadModel( pdf , this.pdfViewer);
            //this.pdfViewer.loadModel( pdf , viewer);
            //viewer.loadExtension("Autodesk.Viewing.MarkupsCore");
            //viewer.loadExtension("Autodesk.Viewing.MarkupsGui");
        });
    });
}
Related