Embed Document Viewer in Home or Custom Page

Hi,

Is there a way to embed the document viewer in Home page or Custom Page, showing the content of the file, not just list of the files?

And instead of showing the Document Viewer as pop up covering current page, will be nice to embed it in an iFrame.

Thx!

  • No offical way I know of, but this code may help...

    ;(function ($, window, document, undefined) {
    	
    	const currentSiteID = window.metaDataSiteID;
    	
    	window.Example = window.Example || {};
    	
    	window.Example.previewCollaborateDocument = function({ siteID = currentSiteID, docID, elemIFrame }) {
    		console.assert(window?.GriffinCommon?.checkDocumentAccess, "Cannot locate required fn");
    		// use Iframe or default preview modal?
    		if (!elemIFrame || !elemIFrame?.length) {
    			const linkID = "myPreviewDocLink";
    			let $link = $(`body>#${linkID}`).length === 0 
    				? $(`<a id="${linkID}" class="hide"></a>`).appendTo("body") 
    				: $(`body>#${linkID}`);			
    			$link.one("click", e => GriffinCommon.checkDocumentAccess(e, siteID, docID)).click();			
    		} else {
    			elemIFrame.attr("src", `./documentHome.action?metaData.siteID=${siteID}&metaData.documentID=${docID}`);
    		}
    	}
    
    })(window.jQuery.noConflict(), window, document);

    You can then call the code passing in the document ID (optionally a site ID if doc in different site) and if you want to display in an iframe, pass in the JQuery wrapper for your iframe, e.g.

    // preview in standard modal
    Example.previewCollaborateDocument({ docID:99999 })
    
    // preview doc in another site
    Example.previewCollaborateDocument({ siteID:1234, docID:99999 })
    
    // preview doc in an iframe
    Example.previewCollaborateDocument({ docID:99999, elemIFrame:$j("#myIframe") })

    Hope this help,

    Andrew