Delphi scan many files to 1 PDF

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
Bumerrrang
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

Hi!
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,
Andrei.

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

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
   begin

      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
      Twain1.TwainPdfStart('C:\multipage.pdf','','','','');


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

Loïc

Bumerrrang
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

Hello,
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?


Regards,
Andrei.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests