Problem with the page navigation buttons(first , last) TWAIN

Discussions about TWAIN scanning in GdPicture.NET using GdPictureImaging.
Post Reply
eradrimo
Posts: 1
Joined: Mon Jan 18, 2016 5:46 pm

Problem with the page navigation buttons(first , last) TWAIN

Post by eradrimo » Mon Jan 18, 2016 6:35 pm

I am new to this, I am using the HTML version Gdpicture.net ; I'm scanning from TWAIN and want to add several pages from my javascript function
acquireTWAINAdf , but when I select a page on the Thumbnail control, the gdviewer doesn't refresh. Also my navigation buttons (next, last) doesn't
work.

the code I'm using is as follows:

Code: Select all

 function acquireTWAINAdf() {
            var status;
            var oGdViewer = document.getElementById("GdViewer1");

            //m_GdPictureImaging.TwainLogStart("c:\\twainlog.txt"); //uncomment this line to generate TWAIN LOG
            m_GdPictureImaging.TwainSelectSource(0);
            m_GdPictureImaging.TwainOpenDefaultSource(0);
            status = m_GdPictureImaging.GetStat();

            if (status == 0) {
                m_GdPictureImaging.TwainSetAutoFeed(true); //todo: we should check if a document feeder is available and correctly selected
                m_GdPictureImaging.TwainSetAutoScan(true);
                m_GdPictureImaging.TwainSetHideUI(true);
                m_GdPictureImaging.TwainEnableDuplex(true);
                m_GdPictureImaging.TwainSetPixelType(1);
                m_GdPictureImaging.TwainSetResolution(200);
                m_GdPictureImaging.TwainSetMultiTransfer(true);

                var ImageID;
                var multipageHandle = 0;
                var imageCount = 0;

                do {
                    ImageID = m_GdPictureImaging.TwainAcquireToGdPictureImage(0);

                    if (ImageID != 0) {
                        imageCount++;

                        oGdViewer.DisplayFromGdPictureImage(ImageID);

                        if (imageCount == 1) {
                            multipageHandle = ImageID;
                            m_GdPictureImaging.TiffSaveAsMultiPageFile(multipageHandle, "multipage.tif", 100);
                            m_NativeImage = m_GdPictureImaging.TiffCreateMultiPageFromGdPictureImage(ImageID);
                        }
                        else {
                            status = m_GdPictureImaging.TiffAppendPageFromGdPictureImage(m_NativeImage, ImageID);
                            m_GdPictureImaging.TiffAddToMultiPageFile(multipageHandle, ImageID);
                            m_GdPictureImaging.ReleaseGdPictureImage(ImageID);
                        }
                        m_GdPictureImaging.ReleaseGdPictureImage(ImageID);
                    }
                    else {
                        status = m_GdPictureImaging.GetStat();
                    }
                } while (m_GdPictureImaging.TwainGetState() > 5/*TWAIN_SOURCE_ENABLED*/ && status == 0);

                if (status != 0) { //report latest error
                    alert("error occured during acquisition. status: " + status);
                }
                if (m_NativeImage != 0) {
                    oGdViewer.DisplayFromGdPictureImage(m_NativeImage);
                    /*thumbnails*/
                    var ThumbnailEx = document.getElementById("ThumbnailEx1");
                    ThumbnailEx.LoadNewThumbnails();
                    ThumbnailEx.AddItemFromGdPictureImage(ImageID);
                }

                m_GdPictureImaging.TwainCloseSource();
                m_GdPictureImaging.TiffCloseMultiPageFile(multipageHandle);
                m_GdPictureImaging.ReleaseGdPictureImage(multipageHandle);
            }
        }

Cedric
Posts: 259
Joined: Sun Sep 02, 2012 7:30 pm

Re: Problem with the page navigation buttons(first , last) T

Post by Cedric » Mon Feb 08, 2016 11:01 am

Hello,

Your ThumbnailEx control should be initialized from the GdViewer control (using the LoadFromGdViewer method).
As described in the documentation, it will load thumbnails from a GdViewer object. If the GdViewer object handles a multipage document, the ThumbnailEx control will generate a thumbnail for each page. Thumbnails will be created asynchronously.

I hope this helps.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests