Using GdPicture with Visual Foxpro

Discussions about GdPicture.NET usage in non managed applications built in vb6, Delphi, vfp, MFC c++ etc...
Post Reply
Hochman
Posts: 6
Joined: Fri Aug 10, 2007 11:09 pm
Location: NY, USA
Contact:

Using GdPicture with Visual Foxpro

Post by Hochman » Wed Apr 11, 2012 12:23 am

I've been using the GdTwain Pro version of the software in my application. I have upgraded to GdPicture for certain features. I need to accomplish 2 things.

1. To scan and create a PDF file via flatbed or ADF of 1 or more documents.
2. When scanning multiple documents, I want to ask the user after each document if there are additional documents to be scanned, and then create a single PDF from all the scanned documents.

I am modifying my original code as I find differences between the old and the new software. I used to say .TwainOpenDefaultSource() with no parameters, however in the new version a parameter is required. What would the parameter be in VFP?

Thank you for your assistance.

Chaim

User avatar
Loïc
Site Admin
Posts: 5586
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Using GdPicture with Visual Foxpro

Post by Loïc » Wed Apr 11, 2012 11:50 am

Hello,

Here a vfp sample to acquire document feeder content into a multipage PDF.

Let me know if you have particular questions.

Code: Select all

PRIVATE oImaging,oGdPicturePDF, ImageID

oImaging = CREATEOBJECT("GdPicture.GdPictureImaging")
oGdPicturePDF = CREATEOBJECT("GdPicture.GdPicturePDF")
WITH oImaging  as "GdPicture.GdPictureImaging"
  .TwainSelectSource_2(application.hWnd)
  .TwainOpenDefaultSource_2(application.hWnd)  && You need to call this function before each scan process
  .TwainSetHideUI(.F.) 
  oGdPicturePDF.NewPDF()
     
  DO WHILE .T.
    ImageID = .TwainAcquireToGdPictureImage_2(application.hWnd)
    If ImageID <> 0 Then
       oGdPicturePDF.AddImageFromGdPictureImage(ImageID, .F., .T.)
       .ReleaseGdPictureImage(ImageID)
    EndIf
    IF .TwainGetState() <= 5 &&TWAIN_SOURCE_ENABLED 
       EXIT
    ENDIF
  ENDDO     

  .TwainCloseSource()
  oGdPicturePDF.SaveToFile("c:\output.pdf")
  oGdPicturePDF.CloseDocument()  
ENDWITH

RELEASE oImaging
RELEASE oGdPicturePDF 
Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest