Free Support Forum -

Post document load- is file still used?


So the way I have started to integrate GroupDocs is like this. All our files are stored as base64 strings. So upon loading the viewer I convert the base64 to a byte array and save the file to a temp directory. Then I give the file location to the viewer that then loads it.

I set the documentLoadCompleted.groupdocs event to make a call that cleans that file up after it has been loaded, only it seems that beyond the loading of the file GroupDocs is still using it.

Is there something I can do for this? Is there a way for me to know when the destroy is called on the widget and kick off a cleanup call then?

It would be great if you guys had more available events to hook into on the javascript side although I know my use of your stuff is most likely different than how others use it but I have some unique situations on how we handle things. (i.e. 100% of our code is generated)


Hello Matt,

First of all, in your scenario it is not necessary to save a document content into the temporary file and then delete that file. There is a “.Stream” method in the GroupDocs.Viewer widget. You have the base64-encoded documents, then you convert them to the byte array, and then create a MemoryStream instance, which wraps that array. And pass this instance to the “.Stream” method. All other will be done by the GroupDocs.Viewer.

But, here is a direct answer on your question. When opening a document, GroupDocs.Viewer converts it to the HTML-compatible form and stores it on the server-side as a cache, in the “temp” subfolder inside the root storage (this is default behaviour). If there is no “.PreloadPagesCount” method in the widget, the end-user will see the document in the browser only when the document will be converted to the HTML-form in full size (all pages). From this moment, when scrolling the pages in the browser, only the cached content will be used.

When performing printing, GroupDocs.Viewer uses image-based cache for creating a print-version of the document and doesn’t use the original file. Only when trying to download the document in the browser, the original document will be requested by the GroupDocs.Viewer.

There is an option .IgnoreDocumentAbsence(Boolean)” in the GroupDocs.Viewer widget. This options prescribes to use exactly the cached content after opening the file, and not to use the target file in any case. So, in order to achieve your goals you should use the next source code:
<%= Groupdocs.Web.UI.Viewer.ClientCode()


After opening the document in the browser you can remove the original file on the server-side.

Of course, if you will try to download the file using the “Download” button or JS API widget method, there will be an error, because such file will be absent. But all other features like page navigation, searching, rotation and so on should work.



Hello Matt,

While testing the previously described functionality, when the original document is removed on the server-side, we have spotted several bugs. In particular, printing and zooming of the document pages is not working, while all other operations are still okay. These bugs are reproduced and submitted to the Jira, we have tied them with this forum thread, and you will obtain a notification, when they will be fixed.

Sorry for this.


The issues you have found earlier (filed as WEB-1505;WEB-1506) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by GroupDocs Notifier.