Scripts are missing - undefined errors

Discussions about DocuVieware integration in GdPicture.NET.
Post Reply
Bluffrat
Posts: 4
Joined: Tue Nov 21, 2017 4:42 pm

Scripts are missing - undefined errors

Post by Bluffrat » Fri Jan 26, 2018 7:59 pm

:? I'm following the sample twain example exactly. Then control renders fine but each button throws an undefined error. Please let me know what is going on.

Thanks!


Capture.JPG

Code: Select all

@{ViewBag.Title = "Index"; Layout = null;}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>DocuVieware - PDF Form Fieds Demo.</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    <script src="~/Scripts/docuvieware-min.js"></script>
    <link href="~/Content/docuvieware-min.css" rel="stylesheet" type="text/css" />
</head>


<body>
    <div id="application_container">
        <div id="toolbar_container">
            <!-- Toolbar -->
            <button onclick="generatePDFA(); return false;">Generate PDF/A</button>
        </div>
        <div id="viewer_container">
            @{
                GdPicture14.WEB.DocuVieware docuVieware = new GdPicture14.WEB.DocuVieware
                {
                    ID = "DocuVieware1",
                    Timeout = 60,
                    Height = new System.Web.UI.WebControls.Unit("100%"),
                    Width = new System.Web.UI.WebControls.Unit("100%"),
                    DisableAnnotationDrawingModePanel = true,
                    SinglePageView = false,
                    ForceScrollBars = false,
                    AllowedExportFormats = "*",
                    MaxUploadSize = 52428800,
                    CollapsedSnapIn = true,
                    EnableMouseModeButtons = false,
                    EnableFileUploadButton = true,
                    EnableLoadFromUriButton = true,
                    EnablePrintButton = true,
                    EnableSaveButton = true,
                    ShowThumbnailsSnapIn = true,
                    ShowBookmarksSnapIn = false,
                    ShowTextSearchSnapIn = false,
                    ShowAnnotationsSnapIn = true,
                    EnableTwainAcquisitionButton = true,
                    EnableThumbnailDragDrop = true
                };
                docuVieware.RenderControl(Output);
            }
        </div>
    </div>
    <script>
        // This function will trigger the custom action handled in TwainAcquisitionDemo.cs
        // a callback function will be called upon generatePDFA success with result that
        // contains binary data in the form of a base64 encoded string
        function generatePDFA() {
            if (DocuViewareAPI.GetPageCount() !== 0) {
                var params = { FileData: "" };
                DocuViewareAPI.PostCustomServerAction("DocuVieware1", true, "generatePDFA", params, function (result) {
                    savePdfAFile("archive.pdf", base64ToPdfBlob(result));
                });
            }
        }
        // This function converts the base64 string to a PDF binary object
        function base64ToPdfBlob(base64) {
            var sliceSize = 1024;
            var byteChars = window.atob(base64);
            var byteArrays = [];
            for (var offset = 0, len = byteChars.length; offset < len; offset += sliceSize) {
                var slice = byteChars.slice(offset, offset + sliceSize);
                var byteNumbers = new Array(slice.length);
                for (var i = 0; i < slice.length; i++) {
                    byteNumbers[i] = slice.charCodeAt(i);
                }
                var byteArray = new Uint8Array(byteNumbers);
                byteArrays.push(byteArray);
            }
            return new Blob(byteArrays, { type: "application/pdf" });
        }
        // This function actually downloads the PDF binary object as a regular file
        function savePdfAFile(name, data) {
            if (data != null && navigator.msSaveBlob) {
                return navigator.msSaveBlob(new Blob([data], { type: "data:attachment/pdf" }), name);
            }
            var url = window.URL.createObjectURL(new Blob([data], { type: "data:attachment/pdf" }));
            var tempLink = $("<a download='" + name + "' href='" + url + "'></a>");
            tempLink.appendTo('body');
            tempLink[0].click();
            tempLink.remove();
        }
    </script>
</body>
</html>
Uncaught TypeError: Cannot read property 'TwainAcquisitionDialog_Click' of undefined
at HTMLButtonElement.onclick (IndexWebix:29)
IndexWebix:29 Uncaught TypeError: Cannot read property 'LoadFromUriDialog_Click' of undefined
at HTMLButtonElement.onclick (IndexWebix:29)
onclick @ IndexWebix:29
IndexWebix:29 Uncaught TypeError: Cannot read property 'LoadFromFile_Click' of undefined
at HTMLButtonElement.onclick (IndexWebix:29)
onclick @ IndexWebix:29
IndexWebix:29 Uncaught TypeError: Cannot read property 'Print_Click' of undefined
at HTMLButtonElement.onclick (IndexWebix:29)

User avatar
Loïc
Site Admin
Posts: 5575
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Scripts are missing - undefined errors

Post by Loïc » Sun Jan 28, 2018 12:34 pm

Hello Roy,

Are you able to share a simple application with us that reproduces the problem?

Please send it through our helpdesk.

Cheers,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest