.NET Server

Generating Microsoft Office Documents Preview using G Suite

In this article

Generating Microsoft Office Documents Preview using G Suite

Using IT Hit G Suite Server Engine you can generate Microsoft Office documents preview using Google G Suite service. The document is exposed to your G Suite account for the time of preview and automatically deleted when preview is completed.

To start the preview call GSuitePreviewDocument() JavaScript function from a web page, passing a document URL and HTML DOM element where the preview will be loaded:


Unlike with G Suite editing, the document is not locked when opened for preview.

Detecting Server Preview Support

To detect if G Suite preview is supported by the server Engine use the GetSupportedFeaturesAsync() JavaScript function and check for Features.GSuite flag:

var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
webDavSession.OpenFolderAsync('https://serv/', null, function(oAsyncResult){
    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oAsyncResult.Result;
        /** @typedef {ITHit.WebDAV.Client.OptionsInfo} oOptionsInfo */
        var oOptionsInfo = oAsyncResult.Result;
        var bGSuite = oOptionsInfo.Features &
                ITHit.WebDAV.Client.Features.GSuite !== 0;
        console.log('G Suite preview support: ' + (bGSuite ? 'yes' : 'no'));

Detecting if Document can be Previewed in G Suite

To find if a document can be previewed in G Suite use the IsGSuiteDocument() JavaScript function. This function extracts document extension and returns true if this type of document can be previewed.

var bGSuiteDoc = ITHit.WebDAV.Client.DocManager.IsGSuiteDocument('https://server/document.docx');
console.log('Document can be edited in G Suite and previewed: ' + (bGSuiteDoc ? 'yes' : 'no'));

Note that G Suite can preview docx, xlsx and pptx document. It can NOT generate a preview for doc, xls and ppt formats.

Next Article:

Creating Google Service Account and Enabling Google API