Recreate iframe

Which product are you using?

PDF.js Express Viewer
PDF.js Express Version

8.7.3

Detailed description of issue
Hi. If I have an instance const instance = getInstance(); - is there a way to recreate iframe if original iframe was destroyed when the modal was closed? I am showing PDF preview in a modal and after closing it the iframe disappears from DOM. But the instance is still there. I don’t really can instance.UI.loadDocument because I’m using config files and sending a blob from parent window to iframe and calling loadDocument from config file.

If every time I open modal I’ll call

PDFJSExpress(
          {
            path: 'patht/to/pdfJsViewer/public',
            config: 'patht/to/pdfJsViewer/config.js',
            licenseKey,
            
          },
          document.getElementById('pdf-container')
        );

then I’ll have multiple viewer instances… Or is there a way how to detect from file config.js that the iFrame will be destroyed? Maybe some event or something else?

Hi there,

Thank you for contacting pdf.js express forums,

We generally recommend you not to re-instantiate the viewer instance, however you could try using the dispose() method: PDFJS Express WebViewer Namespace: UI or
PDFJS Express WebViewer Class: DocumentViewer

A possible solution could be to toggle the viewer modal via visibility:hidden or height:0 / width:0 PDF.js Express Viewer Integration Best Practices | Documentation

Best regards,
Kevin Kim