HTML5 WebViewer script internally crashes and replaces HTML body tag.

59 views
Skip to first unread message

ketan.s...@anzu.org

unread,
Feb 25, 2014, 6:02:06 AM2/25/14
to pdfnet-w...@googlegroups.com
Hi,

We are using MVC4 and added PDFTron's Web Viewer. Below is the code.

@model string
    <script type="text/javascript">
        var url = localStorage.g_puburl;
        $(function () {
            var viewerElement = document.getElementById('viewer');
            alert('1 - control before webviewer load');
            var myWebViewer = new PDFTron.WebViewer({
                type: "html5mobile",
                initialDoc: url,
                config: URL("/Resources/Scripts/WebViewerConfig.js"),
                enableAnnotations: true
            }, viewerElement);
            alert('2 - control before webviewer load');
        });
    </script>
    <div id="viewer" style="height: 100%; "></div>   


This runs find on Desktop. But on Mobile when we load WebViewer script crashes and next set of line does not execute. In Above code Alert -2 Does not show up while opening page from Mobile. Also Once script crashes internally, it removes the Page's Main Body content and replaces with Reader's code. So we cannot go back to previous state of the Page.

Matt Parizeau

unread,
Feb 25, 2014, 1:27:22 PM2/25/14
to pdfnet-w...@googlegroups.com
Hi,

The default behavior of the mobile viewer is to redirect directly to the ReaderControl page because of some issues with iframes on mobile devices.  The way to override this behavior is to use the option mobileRedirect: false, see https://groups.google.com/d/msg/pdfnet-webviewer/nr7iX_UA6ek/gURoAKR0uZcJ

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages