Delphi scan many files to 1 PDF

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
Posts: 2
Joined: Wed Dec 09, 2009 10:06 am

Delphi scan many files to 1 PDF

Post by Bumerrrang » Wed Dec 09, 2009 11:19 am

I've bought this component for scanning documents into PDF files. I am working with Delphi, everything is installed and working properly, but I can't scan many papers to one PDF-file. Did somebody have the same problem? The button in sample 'Scan from ADF to multipage PDF' is doing the same- creating one file. I've tried the duplex mode too, but nothing helped. Could somebody give me an example of the working code?

Best Regards,

User avatar
Site Admin
Posts: 5663
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Delphi scan many files to 1 PDF

Post by Loïc » Thu Dec 10, 2009 5:45 pm

Hi Andrei,

Please write the code you are using to scan in multipage PDF.

This one should work:

Code: Select all

  //Here we will scan in a 24bpp  in multiple page pdf file

   If Twain1.TwainOpenDefaultSource() Then

      Twain1.TwainSetAutoFeed (True); // Set AutoFeed Enabled
      Twain1.TwainSetAutoScan (True); // To  achieve the maximum scanning rate

      Twain1.TwainSetCurrentResolution (Resolution);
      Twain1.TwainSetCurrentPixelType (TWPT_RGB); // RGB
      Twain1.TwainSetCurrentBitDepth (8); // ' 24 bpp

      While Twain1.TwainAcquireToGdPictureImage(Handle) <> 0 do
         nImageID := Twain1.GetNativeImage;
         Twain1.CloseImage (nImageID);
      ShowMessage('Done !');
   end Else
      MessageDlg('can´t open default source, twain state is: '+ IntToStr(Twain1.TwainGetState),
Kind regards,


Posts: 2
Joined: Wed Dec 09, 2009 10:06 am

Re: Delphi scan many files to 1 PDF

Post by Bumerrrang » Fri Dec 11, 2009 10:38 am

The code You'd written is from the sample lake I see, one part just missing (InitScanConfig;). But in documentation I've read, that the function object.TwainAcquireToGdPictureImage (hwnd) (in our case the string is <While Twain1.TwainAcquireToGdPictureImage(Handle) <> 0 do>) is used for converting just one image to PDF (in documentary is written <Acquires a single image, from the currently selected Data Source.>). Your example also scans just one image to PDF file (I had tried it too for each case).
Else in the documentary is described the function <object.TwainAddGdPictureImageToPdf (nImageID)>. It is written there, that <Appends a GdPicture Image into the multipage PDF file created by the TwainPdfStartEx() function.> This is because I think this function must be applied for multiple scanning. And I ask maybe somebody has an example of using this function (I had tried the code from the documentary, but there it is in Visual Basic at first, and at second the same code in Delphi does not work correctly). If nobody has, can somebody give me advise what I should to do? How can I scan multipage into one PDF file?


Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests