Note: The optional GdPicture OCR Tesseract Plugin is needed: https://www.gdpicture.com/products/plugi ... engine.php
- Sample 1: Creating multipage searchable PDF from the content of the document feeder of a scanner:
Code: Select all
Dim nImageID As Long
Dim nCpt As Long
If Imaging1.TwainOpenDefaultSource() Then
Imaging1.TwainSetAutoFeed (True) 'Set AutoFeed Enabled
Imaging1.TwainSetAutoScan (True) 'To achieve the maximum scanning rate
Imaging1.TwainSetCurrentResolution (300) 'We scan in 300 DPI
Imaging1.TwainSetCurrentPixelType (TWPT_BW) 'Black & White scanning
Imaging1.TwainSetCurrentBitDepth (1) ' 1 bpp scanning
Imaging1.TwainPdfOCRStart ("output.pdf")
While Imaging1.CreateImageFromTwain(Me.hWnd) <> 0
nImageID = Imaging1.GetNativeImage
'In AppData we should have ne needed dictionary files
Call Imaging1.TwainAddGdPictureImageToPdfOCR(nImageID, TesseractDictionaryEnglish, App.Path & "\AppData") 'AppData includes dictionary files
Imaging1.CloseImage (nImageID)
Wend
Imaging1.TwainPdfOCRStop
Call Imaging1.TwainCloseSource
Else
MsgBox "can't open default source, twain state is: " & Trim(Str(Imaging1.TwainGetState))
End If
- Sample 2: Creating multipage searchable PDF from a multipage TIFF image:
Code: Select all
Dim nImageID As Long
Imaging1.TiffOpenMultiPageAsReadOnly (True)
nImageID = Imaging1.CreateImageFromFile("multipage.tif")
'In AppData we should have ne needed dictionary files
Call Imaging1.PdfOCRCreateFromMultipageTIFF(nImageID, "output.pdf", TesseractDictionaryEnglish, App.Path & "\AppData") 'AppData includes dictionary files
Call Imaging1.CloseImage(nImageID)
- Sample 3: Creating single page searchable PDF from image:
Code: Select all
Imaging1.CreateImageFromFile ("image.tif")
Call Imaging1.SaveAsPDFOCR("output.pdf", TesseractDictionaryEnglish, App.Path & "\AppData") 'AppData includes dictionary files
Imaging1.CloseNativeImage
- Sample 4: Creating multipage searchable PDF from existing multipage PDF:
Code: Select all
Dim nPage As Long
Dim oImaging As Object, oGdViewer As Object
Dim RasterizedPage As Long
Set oImaging = CreateObject("gdpicturepro5.Imaging")
Set oGdViewer = CreateObject("gdpicturepro5.GdViewer")
oGdViewer.SetLicenseNumber ("XXX")
oImaging.SetLicenseNumber ("XXX")
oGdViewer.LockControl = True
oGdViewer.PdfDpiRendering = 200
oGdViewer.DisplayFromPdfFile ("c:\test.pdf")
For nPage = 1 To oGdViewer.PageCount
oGdViewer.DisplayFrame (nPage)
RasterizedPage = oGdViewer.GetNativeImage
If nPage = 1 Then
oImaging.TwainPdfOCRStartEx ("c:\testocr.pdf")
End If
Call oImaging.TwainAddGdPictureImageToPdfOCR(RasterizedPage, TesseractDictionaryEnglish, App.Path & "\AppData") 'AppData includes dictionary files
Next nPage
oImaging.TwainPdfOCRStop
oGdViewer.CloseImage