Viewer not working after adding script to auto resize window

I’m using the following script from a support chat from earlier today to resize my viewer window. But its not working. Without this script present the viewer works fine. After adding the script (see code below), the viewer never appears. All I see is the gray background of the <div id=“test”…/> window.


As a last resort, I commented out the setWidth, setZoom and setHeight commands. That didn’t help. If I comment out the “containerElement.groupdocsViewer(“on”, “documentLoadCompleted.groupdocs”, function (e)… " command the viewer starts working again (without any resizing). Can you help?

Thanks, Bill

code follows:

<%@ Page Title=“Patient Record Viewer” Language=“C#” MasterPageFile=”~/Site2.Master" AutoEventWireup=“true” CodeFile=“GdViewer.aspx.cs” Inherits=“GdViewer” %>
<%@ Import Namespace=“Groupdocs.Web.UI” %>

<asp:Content ID=“Content1” ContentPlaceHolderID=“MainContent” runat=“server”>

.
.
.
<%= Viewer.ClientCode()
//.SupportTextSelection(false)
.ShowDownload(false)
.ShowFolderBrowser(false)
.ShowPrint(false)
.ShowViewerStyleControl(true)
.TargetElementSelector("#test")
.FilePath(Session[“ViewerFile”].ToString())
.ViewerInstanceId(“doc_viewer1”)
.EnableRightClickMenu(false)
.ShowThumbnails(true)
.OpenThumbnails(false)
.ZoomToFitWidth()
.Width(970)
.Height(800) %>


</asp:Content>

Hello Bill,


We are sorry to hear that you have such issue. The issue reason is that that you have placed resize JavaScript befor the Viewer div. In such case the JavaScript invoked before all DOM elements are created.

To resolve this issue please put JavaScript after Viewer div:
<%= Viewer.ClientCode()
//.SupportTextSelection(false)
.ShowDownload(false)
.ShowFolderBrowser(false)
.ShowPrint(false)
.ShowViewerStyleControl(true)
.TargetElementSelector("#test")
.FilePath(“candy.pdf”)
.ViewerInstanceId(“doc_viewer1”)
.EnableRightClickMenu(false)
.ShowThumbnails(true)
.OpenThumbnails(false)
.ZoomToFitWidth()
.Width(970)
.Height(800) %>


Best regards.

Ah yes, of course. That worked. Thanks Pavel.

Hello,


Glad to hear that.

Best regards.