Products Technologies Demo Docs Blog Support Company

Document Viewer: Long Polling Support for Loading Documents

The Document Viewer now supports long polling for loading documents. This allows an asynchronous loading of documents and is especially useful for large documents or slow connections.

Document Viewer: Long Polling Support for Loading Documents

Preview

The technique discussed in this article is introduced in version 32.3.0, which ships with TX Text Control 32.0 SP3.

Long polling is a technique used to push updates from the server to the client. This will allow the server to push out updates to the client as soon as new data is available. This technique is useful when the server sends new data to the client irregularly.

The server keeps the connection open and returns a stream that can be consumed by the client using JavaScript.

Unlike our Document Editor, which uses WebSockets for a consistent, very long connection, we decided to use this technique for loading documents into the Document Viewer. The huge advantage of this asynchronous loading process is that all pages are streamed to the viewer as they are generated by the server and are available for consumption. This means that while the server is still processing the remaining pages, the user can begin reading and annotating the document. This is a significant advantage over the traditional method of loading the entire document at once, which can take a long time for large documents.

Traditional Loading

The following screen video shows the Document Viewer loading a 196-page document using the old method. The document is loaded in one go, and the user must wait until the entire document is loaded before they can begin reading it. The video shows only the initial loading sequence to illustrate that the viewer is not usable until it is fully loaded.

Loading documents with Document Viewer

Long-Polling Loading

Now, let's see the same document being loaded using the new long-polling method. The document is loaded in chunks, and the user can start reading it as soon as the first pages are available.

Loading documents with Document Viewer

Network Traffic

In the Google Chrome F12 Developer Tools, you can see the network traffic of the long-polling requests. The server sends the pages as they are generated, and the client consumes them immediately. Pay attention to the request type which is fetch instead of XHR.

Network traffic of long-polling requests

Conclusion

Using long-polling for loading documents into the Document Viewer is a significant improvement in terms of user experience. The user can start reading and annotating the document as soon as the first pages are available. This asynchronous loading process is a great addition to the Document Viewer and will be available in the next service pack.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Related Posts

ASP.NETASP.NET CoreDocument Viewer

High-Performance Text Replacement in Large DOCX Files using C# .NET

Learn how to efficiently replace text in large DOCX files using C# .NET and the ServerTextControl component from Text Control. This article demonstrates the performance benefits of using the…


ASP.NETASP.NET CoreDocument Viewer

Document Viewer 33.2.1 Released: New Event and Bug Fixes

This service pack includes important bug fixes and improvements to enhance the stability and performance of the Document Viewer. In addition, a new event has been introduced to provide developers…


ASP.NETASP.NET CoreDocument Viewer

Use PDF.js to Render PDF Documents within the Document Viewer

With the release of the latest release candidate of the Document Viewer, we released the ability to use PDF.js to render PDF documents. This article shows how to use this new feature.


ASP.NETASP.NET CoreDocument Viewer

Document Viewer 31.2.2 RC1 Released with New Features

We have just released the first release candidate (RC) of the next version of the Document Viewer. This article lists the new features and improvements in this major release.


ASP.NETWindows FormsWPF

TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 3 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…