Currently I use an external ‘command line’ driven program to scan documents, convert them into Adobe Acrobat files and save them on a server, but this means the end user also having to purchase a licence for ‘scantopdf’. I then place a link in a database pointing to the file to recall them at a later date (I don’t want to save the binaries in the database). In effect a master record may have many scanned documents linked to it.
I would like to go to a complete XOJO solution. I have been playing about with MBS TWAIN Plugin, and I have dynapdf. Some of the documents I scan can be upwards of 50-100 sides of A4 so not small image files, but thankfully smaller .pdf files. My needs are relatively simple, scan the pages, create a .pdf, save all the pages, and then add the file path link to the database form where it can be later launched.
Does anyone else have any other suggestions, or are using the MBS/DynaPDF solution (I have only just started playing with the demo files of this - it may well be this turns out to be fine).
I have an older version of Vintasoft Twain for a MSACCESS solution, didn’t consider that, although I have not done a lot with ActiveX in XOJO so will have a play. It is windows environment Matthew, and scannera vary, Epson, Fujitsu and Kojica Minolta. The predominant high volume one is the Fujitsu. I’ll take a look at the code, although I wouldn’t bank on my ability to transpose it
lookup EZTW32.dll. It’s very easy to use using some declares.
e.g. on of the declares:
Function AcquireToFile(f As Folderitem = Nil) As Boolean
Dim retVal As Boolean
Dim fItem as FolderItem
Const thisModule = "- AcquireToFile"
#If TargetWin32
If Self.IsAvailable Then
Soft Declare Function TWAIN_AcquireToFilename Lib "EZTW32.dll"(hwndApp As Integer, pszFile As CString) As Integer
Dim i As Integer
If f <> Nil Then
fItem = f
Elseif fItem Is Nil Then
fItem = TemporaryFolder.Child("sjgeztwaintemp.bmp")
if fItem.Exists then
fItem.Delete
end if
End If
If fItem <> Nil Then
i = TWAIN_AcquireToFilename(0,fItem.AbsolutePath)
If i = 0 Then
If fItem.Exists Then
AcquiredPicture = fItem.OpenAsPicture
If AcquiredPicture <> Nil Then
retVal = True
End If
Else
reportError "File not created" + thisModule
End If
Else
Select Case i
Case -1
reportError "Acquire failed OR user cancelled File Save dialog" + thisModule
Case -2
reportError "file open error (invalid path or name, or access denied)" + thisModule
Case -3
reportError "(weird) unable to lock DIB - probably an invalid handle" + thisModule
Case -4
reportError "writing BMP data failed, possibly output device is full" + thisModule
End Select
End If
Else
reportError "Nil FolderItem" + thisModule
End If
If retVal = False Then
AcquiredPicture = Nil
End If
End If
#EndIf
Return retVal
End Function
Looking at the options, and prices Vintasoft may be the way to go. Do you have any sample code Greg that I can adapt, or pointers to more help on using windows .dll’s etc? First time playing with activex/dll and although I have read the XOJO help pages I am not sure where to start.
This is what I have tried so far;
soft declare function Acquire Lib "VZTwain" () As Boolean
dim boo as Boolean
boo=Acquire[/code]
I get an error when I run the code, "Could not load Acquire from VZTwain"
The VB6 code to do a scan is this, i just wanted to 'connect' to the scanner to see if I was accessing the dll correctly
[code]Private Sub StartScan()
VSTwain1.StartDevice()
If VSTwain1.SelectSource() = 1 Then
VSTwain1.ShowUI = True
VSTwain1.Acquire()
End If
End Sub
Private Sub VSTwain1_PostScan(ByVal flag As Long)
If flag <> 0 Then
If VSTwain1.ErrorCode <> 0 Then
MsgBox VSTwain1.ErrorString
End If
Else
Set Image1.Picture = VSTwain1.GetCurrentImage()
If Not VSTwain1.SaveImage(0, "c:\\test.tiff") Then
MsgBox(VSTwain1.ErrorString)
End If
End If
End Sub
Yeah, don’t do it that way. Add the VSTwain ActiveX control to your project and then put an instance of the control onto the layout from where you will be scanning and name it VSTwain1. Then your code would look something like this…
VSTwain1.showUI = 0
VSTwain1.autoBright = 1
VSTwain1.fileFormat = VSTWAINLib.enumFileFormat.Jpeg
VSTwain1.showIndicators = 0
call VSTwain1.OpenDataSource
VSTwain1.pixelType = VSTWAINLib.enumPixelType.RGB
VSTwain1.feederEnabled = 0 //Don't use the feeder
VSTwain1.resolution = 72 // DPI of the scan
VSTwain1.pageSize = 1 'A4, A4Letter
VSTwain1.autoCleanBuffer = 1
tmpint = VSTwain1.AcquireModal()
if tmpint = 1 then
VSTwain1.jpegQuality = 100
f = SpecialFolder.Temporary.child(format(d.TotalSeconds,"0")+".jpg")
if VSTwain1.SaveImage(0,f.AbsolutePath) = 1 then
//Now open the file
dim p as Picture
p = Picture.Open(f)
//Delete the file
f.Delete
//Return the picture
return p
end if
If you wish to use the PostScan event, it’s available right on the control instance.
Greg, added the controls as suggested. Placed the code as you suggested on a button action. Followed it through the debugger, no errors but did not start the scanner either. Any ideas, tmpint=0, never changes to 1 so the code is never executed.
I have the evaluation version so when I click the xojo button the vintasoft ‘Evaluate’ dialog box comes up to purchase/evaluate etc. so the activex is kicking in, click evalkuate, nothing happens. The scanner however does not start.
Full code below;
[code] dim tmpint as integer
dim f as FolderItem
dim d as new date
VSTwain1.pixelType = VSTWAINLib.enumPixelType.RGB
VSTwain1.feederEnabled = 0 //Don’t use the feeder
VSTwain1.resolution = 72 // DPI of the scan
VSTwain1.pageSize = 1 'A4, A4Letter
VSTwain1.autoCleanBuffer = 1
tmpint = VSTwain1.AcquireModal()
if tmpint = 1 then
VSTwain1.jpegQuality = 100
f = SpecialFolder.Temporary.child(format(d.TotalSeconds,“0”)+".jpg")
if VSTwain1.SaveImage(0,f.AbsolutePath) = 1 then
//Now open the file
dim p as Picture
p = Picture.Open(f)
//Delete the file
f.Delete
//Return the picture
'return p
end if
Look at the VSTwain docs. I believe that you need to set the datasource somewhere (it was not located in the method I showed you, but there’s often two interfaces on a scanner)
The other thing you can try is setting the showIndicators and ShowUI property to 1. That should cause TWAIN to show you the scanning interface.
Hmm, been playing with this but cannot get Vintasoft to scan. Whats even more peculiar is that pressing the ‘scan’ button on my test window puts up the ‘Evaluate Vintasoft’ box, but the scan interface does not show. The project from that point will then not compile. It gives no errors, won’t run in the IDE. Even if I reboot the machine and/or XOJO the project file becomes unusable, in fact its almost as if it becomes corrupted in some form.
Anyone come across this sort of behaviour befiore with XOJO files. I must say its the first time I have come up againts the ‘corruption’ issue, but it is also the first time I have tried to use an activex control.
I can reconstruct the project again from scratch, it will compile the first time, and then not run again.
Tried many ways around this, but can recreate the ‘bug’ each time as above. Anyone have any suggestions as to why, after the first run of the program the project file will no longer compile or run?