PDF File size

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
rongrout
Posts: 4
Joined: Thu Jul 09, 2009 9:58 am

PDF File size

Post by rongrout » Thu Nov 26, 2009 3:07 pm

I am evaluating this software and am creating multi page pdf files for our system but the file sizes are much too big.
For example, one three page scan came out at 4.1mb although, when I resized the document in acrobat, it came down to 501k.
I have looked but cannot find a way to control the compression rate and therby reduce the file size.
Can you help me solve this please?

regards
Ron

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

Re: PDF File size

Post by Loïc » Thu Nov 26, 2009 5:27 pm

Hi,

You have several way to optimize the file size:

- Reducing the bit depth of the scanner image using color reduction function such as ConvertTo1bpp(), Convertto8bppQ()...
- Resizing the image using the ResizeImage() function.

Also, on GdPicture Pro, you can control the JPEG compression rate using the PdfGetJpegQuality() function.

With best regards,

Loïc

rongrout
Posts: 4
Joined: Thu Jul 09, 2009 9:58 am

Re: PDF File size

Post by rongrout » Mon Nov 30, 2009 1:25 pm

I have tried the convert to 1bbp but it does not appear to make any difference.

My code is below, have I done something wrong?


Code: Select all

Private Sub Command12_Click()


'Here we will scan in a 24bpp  in multiple page pdf file
   Dim nImageID As Long
   Dim nCpt As Long

Filename2 = "W:\" & RTrim(Text1.Text) & docno & ".pdf"
'Filename3 = "X:\" & RTrim(Left(lineoftext, 10)) & docno & ".pdf"

'Twain1.TwainSelectSource
   If Twain1.TwainOpenDefaultSource() Then
      InitScanConfig
    
     ' Twain1.CropBorders
   '  Twain1.SetContrast (20)
     Twain1.TwainSetCurrentImageFileFormat TWPT_PDF
     
 
      Twain1.TwainSetHideUI (False)
      Twain1.TwainSetAutoFeed (True)  'Set AutoFeed Enabled
      Twain1.TwainSetAutoScan (True) 'To  achieve the maximum scanning rate
      Twain1.TwainSetAutoSize (True)
      Twain1.TwainSetCurrentResolution (120)
      Twain1.TwainSetCurrentPixelType (TWPT_GRAY)
      Twain1.TwainSetAutomaticBorderDetection (True)
      Twain1.TwainSetPaperSize (1)
  '    Twain1.TwainSetCurrentPixelType (TWPT_RGB) 'RGB
      Twain1.TwainSetCurrentBitDepth (1) ' 24 bpp
      Twain1.TwainPdfStart (Filename2)
     Twain1.ConvertTo1Bpp
      
      
      Do
        nImageID = Twain1.TwainAcquireToGdPictureImage(Me.hWnd)
    '    Call ApplyImageFilters(nImageID)
    '    If chkPreview.Value = 1 Then Call DisplayNativeImage
        
        
        
        Call Twain1.TwainAddGdPictureImageToPdf(nImageID)
        Twain1.CloseImage (nImageID)
      Loop While Twain1.TwainGetState > TWAIN_SOURCE_OPEN
      Twain1.TwainPdfStop
      Call Twain1.TwainCloseSource
 '     MsgBox "Done !"
 '     Dim fso
  '    Set fso = CreateObject("Scripting.FileSystemObject")
   '   fso.COPYFILE Filename2, Filename3, True
      
   Else
      MsgBox "can't open default source, twain state is: " & Trim(Str(Twain1.TwainGetState))
   End If

End Sub



Regards
Ron

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

Re: PDF File size

Post by Loïc » Mon Nov 30, 2009 1:28 pm

Hi,

Please move:

Code: Select all

Twain1.ConvertTo1Bpp
after:

Code: Select all

nImageID = Twain1.TwainAcquireToGdPictureImage(Me.hWnd)
Kind regards,

Loïc

rongrout
Posts: 4
Joined: Thu Jul 09, 2009 9:58 am

Re: PDF File size

Post by rongrout » Mon Nov 30, 2009 6:06 pm

I have downloaded an evaluation copy of gdpicture and have tried all that I can think of with bit sizes etc but cannot reduce the size of the files.

I have tried with PdfSetJpegquality (25) also 50 and 75 and 100 but the file size does not change.
I have tride that line in several different places but still no change.
I am sure that I am doing something wrong but cannot find what.
Can you help please?

coding follows:

Code: Select all

'Twain1.TwainSelectSource
   If twain1.TwainOpenDefaultSource() Then
      InitScanConfig
    
     ' Twain1.CropBorders
   '  Twain1.SetContrast (20)
     twain1.TwainSetCurrentImageFileFormat TWPT_PDF
     
 
      twain1.TwainSetHideUI (False)
      twain1.TwainSetAutoFeed (True)  'Set AutoFeed Enabled
      twain1.TwainSetAutoScan (True) 'To  achieve the maximum scanning rate
      twain1.TwainSetAutoSize (True)
      twain1.TwainSetCurrentResolution (120)
      twain1.TwainSetCurrentPixelType (TWPT_GRAY)
      twain1.TwainSetAutomaticBorderDetection (True)
      twain1.TwainSetPaperSize (1)
  '    Twain1.TwainSetCurrentPixelType (TWPT_RGB) 'RGB
      twain1.TwainSetCurrentBitDepth (4) ' 24 bpp
       twain1.PdfSetJpegQuality (50)
     twain1.TwainPdfStart (Filename2)
      
      
      Do
        nImageID = twain1.TwainAcquireToGdPictureImage(Me.hWnd)
    '    twain1.ConvertTo4Bpp
    '    Call ApplyImageFilters(nImageID)
    '    If chkPreview.Value = 1 Then Call DisplayNativeImage
        
        
        
        Call twain1.TwainAddGdPictureImageToPdf(nImageID)
        twain1.CloseImage (nImageID)
      Loop While twain1.TwainGetState > TWAIN_SOURCE_OPEN
      twain1.TwainPdfStop
      Call twain1.TwainCloseSource
 '     MsgBox "Done !"
 '     Dim fso
  '    Set fso = CreateObject("Scripting.FileSystemObject")
   '   fso.COPYFILE Filename2, Filename3, True
      
   Else
      MsgBox "can't open default source, twain state is: " & Trim(Str(twain1.TwainGetState))
   End If




regards
Ron

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

Re: PDF File size

Post by Loïc » Mon Nov 30, 2009 6:15 pm

Ron,

Did you see my previous suggestion ??

Do you want to create black & white PDF or a colour PDF ?

Kind regards,

Loïc

rongrout
Posts: 4
Joined: Thu Jul 09, 2009 9:58 am

Re: PDF File size

Post by rongrout » Mon Nov 30, 2009 6:51 pm

I want to create a grey scale pdf, multiple pages etc.

It works fine apart from the file size which varies depending what scanner I am using.

On three particular machines the file is about 4.5mb and I have tried reducing to 4 bpp without it making a significant difference.

I then tried gdpicturepro so that I could use the PdfSetJpegQuality method but I cannot get that to make a difference either!!

I realise it must be me but I have tried moving the commands etc but with no success.

Any ideas would be appreciated.

thank you

Ron

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

Re: PDF File size

Post by Loïc » Mon Nov 30, 2009 6:54 pm

Hi,

As I said in previous post you can:

- Convert your scanned image to 1bpp
- or resize the acquired image using the ResizeImage() function just after this line:

Code: Select all

nImageID = twain1.TwainAcquireToGdPictureImage(Me.hWnd)
Kind regards,

Loïc

gukrenn
Posts: 2
Joined: Fri Dec 04, 2009 8:41 am

Re: PDF File size

Post by gukrenn » Fri Dec 04, 2009 9:25 am

Hi,
im an encvountering the same problem. Besides this issue the ActiveX works fine for me.
Bought only the standard version of gdTwain, because i thought picture compression would be pdf standard. But it seems not to be...

In my case an uncompressed pdf is especially tragic, because the company I'm developing for sometimes uses veeery slow WAN lines (in one case only 512 kbit/s !!!!).
They insist on pdfs so scanning and storing as jpg is no option.

Do you have an suggestions?
* is there any possibilty with the standard version to solve the problem?
* is it possible to upgrade to the gdTwain PRO on a special price?
* is there any (cheap) external tool to compress the picture in the pdf after the creation?

Thanks in advance,
Guenther

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

Re: PDF File size

Post by Loïc » Fri Dec 04, 2009 11:34 am

Hi,
i thought picture compression would be pdf standard. But it seems not to be...
You are wrong, we use compression for any kind of image embed in PDF.

I suggest you to download the latest version available on our website.

Then, if you consider your PDF as "not compressed enough" you can send us a copy of the file to esupport (at) gdpicture (dot) com to investigate on your problem.

Kind regards,

Loïc

gukrenn
Posts: 2
Joined: Fri Dec 04, 2009 8:41 am

Re: PDF File size

Post by gukrenn » Thu Dec 10, 2009 11:26 pm

Hi,
thanks for all the help.

After my tests on different PCs in my environment (it worked correctly on all machines) I did the Installation of the latest version of the ocx at my customers site by myself - and now it works fine.
Seems they didn't install the software properly...

Thanks,
Guenther

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest