Home | About us | Overview | Softwares - Downloads | Evaluate | Order | Support | old forums | Contact | F.A.Q. | Documentations | Search | Sitemap

Scanning to PDF

Example requests & Code samples for any GdPicture Softwares.

Scanning to PDF

Postby 2basix on Thu May 24, 2007 10:04 am

Is there a way to scan documents to multiple page PDF ?
--== Keep IT Basic ==--
User avatar
2basix
 
Posts: 8
Joined: Wed May 23, 2007 2:23 pm
Location: Netherlands

Postby Loïc on Tue Jun 05, 2007 6:47 pm

- Sample for GdPicture V5: scanning-pdf-t15.html#p1761






- VB6 sample for GdPicture V4:




Code: Select all

'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


User avatar
Loïc
Site Admin
 
Posts: 1002
Joined: Tue Oct 17, 2006 11:48 pm
Location: France

Postby Loïc on Wed Jun 06, 2007 4:56 pm

Note: This sample works with GdPicture Pro 3.7 Edition and superior.
User avatar
Loïc
Site Admin
 
Posts: 1002
Joined: Tue Oct 17, 2006 11:48 pm
Location: France

multipage PDF scanning

Postby ggilal on Fri Oct 26, 2007 2:24 pm

HI!

Thanks for the code example. If my scanner is not an ADF scanner how would it be possible to scan docs to a multipage pdf thru VB/VBA code? My scanner uses a "next" button when the file format is set to pdf so that I am allowed to place another page into the scanner that will be appended to the PDF.

Thanks again,
Gil
ggilal
 
Posts: 1
Joined: Fri Oct 26, 2007 2:18 pm

Is there special syntax for VBA?

Postby LotusGuy on Mon Dec 03, 2007 5:47 am

I would like to use this demo code but I am having problems with the (Me.hWnd) references. It gives me a "Me not valid outside of class scope"

I may be missing something really stupid here but I am at a loss...

Thanks!
LotusGuy
 
Posts: 8
Joined: Mon Dec 03, 2007 5:42 am

Postby Loïc on Mon Dec 03, 2007 10:45 am

Hi,

You can use 0 if you are inside a class.


Regards,

Loïc
User avatar
Loïc
Site Admin
 
Posts: 1002
Joined: Tue Oct 17, 2006 11:48 pm
Location: France

Re: Scanning to PDF

Postby Loïc on Thu Mar 20, 2008 1:27 pm

With GdPicture V5 it is a bit easier:


Code: Select all
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 If
User avatar
Loïc
Site Admin
 
Posts: 1002
Joined: Tue Oct 17, 2006 11:48 pm
Location: France


Return to Example requests & Code samples

Who is online

Users browsing this forum: No registered users and 1 guest