'Here we will scan in a 24bpp in multiple page pdf file
Dim nImageCount As Long
Dim nImageID As Long
Dim nCpt As Long
If oGdPicture.TwainOpenDefaultSource() Then
nImageCount = 0
oGdPicture.TwainSetAutoFeed (True) 'Set AutoFeed Enabled
oGdPicture.TwainSetAutoScan (True) 'To achieve the maximum scanning rate
oGdPicture.TwainSetCurrentResolution (300)
oGdPicture.TwainSetCurrentPixelType (TWPT_RGB) 'RGB
oGdPicture.TwainSetCurrentBitDepth (8) ' 24 bpp
oGdPicture.PdfNewPdf ("output.pdf")
While oGdPicture.CreateImageFromTwain(Me.hWnd) <> 0
nImageID = oGdPicture.GetNativeImage
nImageCount = nImageCount + 1
Call oGdPicture.PdfAddImageFromImageID(nImageID)
oGdPicture.CloseImage (nImageID)
Wend
For nCpt = 1 To nImageCount
Call oGdPicture.PdfSetPageDimensions(oGdPicture.PdfGetImageWidth(nCpt), oGdPicture.PdfGetImageHeight(nCpt))
oGdPicture.PdfNewPage
Call oGdPicture.PdfDrawImage(nCpt, 0, 0, oGdPicture.PdfGetImageWidth(nCpt), oGdPicture.PdfGetImageHeight(nCpt))
oGdPicture.PdfEndPage
Next nCpt
oGdPicture.PdfSavePdf
Call oGdPicture.TwainCloseSource
MsgBox "Done !"
Else
MsgBox "can't open default source, twain state is: " & Trim(Str(oGdPicture.TwainGetState))
End If
Dim nImageID As Long
If Imaging1.TwainOpenDefaultSource() Then
Imaging1.TwainSetAutoFeed (True) 'Set AutoFeed Enabled
Imaging1.TwainSetAutoScan (True) 'To achieve the maximum scanning rate
Imaging1.TwainSetCurrentResolution (300)
Imaging1.TwainSetCurrentPixelType (TWPT_RGB) 'RGB
Imaging1.TwainSetCurrentBitDepth (8) ' 24 bpp
Imaging1.TwainPdfStart ("output.pdf")
While Imaging1.CreateImageFromTwain(Me.hWnd) <> 0
nImageID = Imaging1.GetNativeImage
Call Imaging1.TwainAddGdPictureImageToPdf(nImageID)
Imaging1.CloseImage (nImageID)
Wend
Imaging1.TwainPdfStop
Call Imaging1.TwainCloseSource
MsgBox "Done !"
Else
MsgBox "can't open default source, twain state is: " & Trim(Str(Imaging1.TwainGetState))
End IfReturn to Example requests & Code samples
Users browsing this forum: No registered users and 0 guests