Code: Select all
If theScanner.TwainOpenDefaultSource() Then
done = False
page = 0
filePathname = GetTempPath() & "\" & "ScanTestFullDocument" & testNumber & ".pdf"
pageBasePathname = GetTempPath() & "\" & "ScanTestDoc" & testNumber & "Page"
UpdateStatus "Configure theScanner..."
With theScanner
.TwainSetHideUI True
.TwainSetCurrentResolution 150
.TwainSetCurrentPixelType TWPT_GRAY
.TwainSetCurrentBitDepth (8)
.TwainSetAutoFeed True
.TwainSetAutoScan False
.TwainSetAutoSize False
.TwainSetAutomaticDeskew False
.TwainSetPaperSize USLETTER
End With
UpdateStatus "TwaindPdfStartEx..."
If theScanner.TwainPdfStartEx(filePathname) = 0 Then
While Not done
page = page + 1
UpdateStatus "TwainAcquireToGdPictureImage Page " & page & " ..."
If theScanner.TwainAcquireToGdPictureImage(hwnd) = 0 Then
done = True
Else
theViewer.SetNativeImage (theScanner.GetNativeImage())
theViewer.ImageClosed
pageThisPathname = pageBasePathname & page & ".pdf"
theScanner.SaveAsPDFEx pageThisPathname
UpdateStatus "TwainAddGdPictureImageToPdf Page " & page & " ..."
theScanner.TwainAddGdPictureImageToPdf (theScanner.GetNativeImage)
theScanner.CloseNativeImage
End If
Wend
UpdateStatus "TwainPdfStop, Page Count = " & page
theScanner.TwainPdfStop
End If
UpdateStatus "TwainCloseSource, Page Count = " & page
theScanner.TwainCloseSource
UpdateStatus "Done, Page Count = " & page
Else
UpdateStatus "TwainOpenDefaultSource failed."
End If