NTKO Office Online Editing Control Issues and Solutions

NTKO Office online preview plugin: http://www.ntko.com/

Issue: Saving fails with "No open document" error in Firefox or Chrome, while Internet Explorer works correctly.

Cause: Different browser implementations execute methods differently. IE embeds the control directly in the page, whereas Firefox and Chrome handle callbacks through JavaScript functions.

Solution:

For Internet Explorer, add the following code direct in the page:

<script language="javascript" type="text/javascript" for="TANGER_OCX" event="OnDocumentOpened(TANGER_OCX_str,TANGER_OCX_obj)">
    TANGER_OCX_OnDocumentOpened(TANGER_OCX_str, TANGER_OCX_obj);
</script>

Firefox and Chrome require modifications in the control's JavaScript file (ntkoofficecontrol.js). Under the condition if (browser == "firefox"), locate the ForOndocumentopened="OnComplete3" property and ensure that the OnComplete3 callback function includes the necessary handling.

document.write('<object id="TANGER_OCX" type="application/ntko-plug" codebase="/module/ntko/ofctnewclsid.cab#version=5,0,3,0" width="100%" height="750" ForOndocumentopened="OnComplete3" ForOnSaveToURL="OnSaveToURL" ');

Issue: Opening PDF files results in "File access error".

Cause: PDF file support has not been enabled.

Solution: Enable PDF support by adding the following code in the document opening and control initialization method (requires ntokoledocall.cab component; version 4.0.0.0 corresponds to the FileVersion=4,0,0,5 in ntkooledocall.inf):

TANGER_OCX_OBJ.AddDocTypePlugin(".pdf", "PDF.NtkoDocument", "4.0.0.5", "/module/ntko/ntkooledocall.cab", 51, true);

Issue: Even with PDF support added, IE still shows "File access error" or "Document loading failed" when previewing.

Cause: Incorrect binary stream output from the backend.

Solution: Output binary streams properly using the following approach to avoid issues. Pay attention to these headers (if problems persist, research browser-specific binary stream handling for different file types like PDF and Word):

response.AddHeader("content-type", "application/octet-stream");

response.AddHeader("Content-Disposition", "inline; filename=" + fileName);

public void OpenServerFile(string filePath, string fileName)
{
    // Read document as binary stream; ensure it's standard format for correct client-side rendering
    // Example uses a local Word document, but can be adapted for database retrieval or other sources

    FileInfo fileInfo = new FileInfo(filePath);
    FileStream fileStream = fileInfo.OpenRead();

    HttpResponse httpResponse = System.Web.HttpContext.Current.Response;
    HttpRequest httpRequest = System.Web.HttpContext.Current.Request;

    httpResponse.AddHeader("content-type", "application/octet-stream");
    httpResponse.AddHeader("Content-Disposition", "inline; filename=" + fileName);

    byte[] buffer = new byte[(int)fileStream.Length];
    fileStream.Read(buffer, 0, buffer.Length);
    fileStream.Close();
    httpResponse.BinaryWrite(buffer);
    httpResponse.Flush();
    httpResponse.End();
}

Issue: In Firefox and Chrome, saving a file returns an "error" value in the control’s JavaScript callback, and browser requests return HTTP 500 errors without reaching the server.

Cause: The form elemant containing the control has the runat="server" attribute, which interferes with client-side form submission.

Solution: Remove the runat="server" attribute from the form tag.

Issue: Occasionally, documents fail to load during control initialization with a "Document loading failed" message.

Cause: The document loading method is executed before the control is fully initialized.

Solution: Introduce a delay before calling document-opening methods such as BeginOpenFromURL. Example implementation:

// Delay execution to allow control initialization
setTimeout(function () {
    TANGER_OCX_OBJ.BeginOpenFromURL(URL, true, false);
}, 1000);

Tags: ntko office online-editing firefox Chrome

Posted on Wed, 04 Nov 2026 16:29:09 +0000 by connex