Good morning,
At our company we build an ASP.NET webforms application. We are considering using the DocumentUltimate product for mainly opening PDF and MS Office files. I have implemented some code to make the viewer work. We show a normal default.aspx page on where we open a tab to show some content and the DocumentViewer. So if we add the DocumentViewer in a normal way it will not work because we already loaded the page, the header is rendered and the control is to late to add viewer.js to the head of the DOM. To get rid of this problem we added some code in our OnPreRender method which does this for us:
if (Page.IsPostBack)
{
MethodInfo info = typeof(DocumentViewer).GetMethod("GetScriptTags", BindingFlags.Instance | BindingFlags.NonPublic);
string[] script = (string[])info.Invoke(documentViewer, new object[0]);
for(int i = 0; i < script.Length; i++)
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "tsfpreview" + i.ToString(), script[i], false);
}
After this the viewer still not works, so I looked in viewer.js and took the code which renders the documents and put them in my own script as follows:
TSFMainScript.AppendScript(string.Format(@"var element = document.getElementById('{0}');
// Find the script within the panel which is added by the control and move it to the header.
jQuery(element).find('script').appendTo(document.head);
for (var i = 0; i < documentViewersToRender.length; i++)
renderDocumentViewer(documentViewersToRender[i]);
// Empty the viewers so it is not rendered double when there are multiple viewers on the page.
documentViewersToRender = [];
", this.panel.ClientID));
}
After this the viewer starts working and we can use it like we want. On the page we have a grid and next to that the DocumentViewer. A certain column in the grid contains a path to a document, so when we switch rows in the grid we take this path and set it to DocumentViewer.DocumentPath, append the upper code again (each request) and update our updatePanel where it stands on.
This still works great and the DocumentViewer is showing the correct files after each row switch.
The main problem we are facing now is that the viewer stops working in IE and Edge after 3 or 4 row switches.
In Chrome and Firefox the DocumentViewer keeps working.
The only difference I can spot is that when a document is fetched with partial Content request, the last one is missing when the DocuemntViewer stops working. Also I don't see DecryptWorker.js passing by, which I do see when the viewer works.
I hope you can help me and point me in the right direction. If we cannot fix this we have to look for another product to show our documents.
If you need more information please let me know.
Kind regards,
Roel Winkels