ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 SaveToFilePDF creating huge PDFs
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

EricNat

USA
37 Posts

Posted - Sep 26 2011 :  14:12:41  Show Profile  Reply
I am using TImageEnMView to acquire a scan using TWAIN and then save the acquired image as a PDF using SaveToFilePDF. The issue is that it is creating huge PDF files. A 4 page B&W scan at 200dpi is about 45MB. When I open it in Acrobat and "optimize" it, the file shrinks to 600kb. Here is what I am doing:

ScanView->MIO->SelectAcquireSource(ieaTWain);
if (ScanView->MIO->Acquire(ieaTWain)) {
ScanView->MIO->SaveToFilePDF("testscan.pdf");
}

I have tried adjusting the PDF_Compression value for each page, but that doesn't seem to affect anything.

Any thoughts?

Thanks,
Eric

fab

1310 Posts

Posted - Sep 26 2011 :  22:23:32  Show Profile  Reply
Hello,
you have to specify a compression method.
For example, for B&W images, the best is G4FAX, so you should write:

ScanView->MIO->Params[0]->PDF_Compression  = ioPDF_G4FAX;
ScanView->MIO->Params[0]->SamplesPerPixel = 1;
ScanView->MIO->Params[0]->BitsPerSample = 1;
ScanView->MIO->DuplicateCompressionInfo();
ScanView->MIO->SaveToFilePDF("testscan.pdf");

Go to Top of Page

EricNat

USA
37 Posts

Posted - Sep 26 2011 :  23:11:52  Show Profile  Reply
I have tried adding that code, but I still get large PDF files. Setting the compression doesn't seem to affect anything. Each page results in about 10MB in the PDF. Do you have any other thoughts?

Thank you.
Go to Top of Page

fab

1310 Posts

Posted - Sep 27 2011 :  04:57:25  Show Profile  Reply
It must work. I just re-tested it.
Make sure that:
1) BitsPerSample and SamplesPerPixel are both "1"
2) the input/output parameters are assigned at index "0"
3) you call DuplicateCompressionInfo()
4) you always reference the embedded "MIO" object, instead of a possible external TImageEnMIO object

Four common US Letter (at 200 dpi) pages should require about 15KB (while uncompressed is about 45MB).
This is the code I used for the test:

ImageEnMView1->MIO->SelectAcquireSource();
ImageEnMView1->MIO->Acquire();
ImageEnMView1->MIO->Params[0]->PDF_Compression = ioPDF_G4FAX;
ImageEnMView1->MIO->Params[0]->BitsPerSample = 1;
ImageEnMView1->MIO->Params[0]->SamplesPerPixel = 1;
ImageEnMView1->MIO->DuplicateCompressionInfo();
ImageEnMView1->MIO->SaveToFilePDF("test.pdf");
Go to Top of Page

EricNat

USA
37 Posts

Posted - Sep 28 2011 :  23:41:30  Show Profile  Reply
Thank you Fabrizio. I ended up getting it to work by doing two things -- I updated the component to the latest version (I was using an older version) and I had to also either scan in B&W or run ConvertToBW_FloydSteinberg() on each page before compressing and saving. That did the trick. Thank you.
Go to Top of Page

rogmartins

Brazil
2 Posts

Posted - Oct 11 2011 :  05:20:48  Show Profile  Reply
Hi !
Iīm having the same related trouble with both tif and pdf formats using the version 3.1.2
I canīt compile the code you suggested because it doesnīt have the DuplicateCompresseionInfo method.

How can i correct this anyway ?

My clients are so annoyed.

Thanks
Go to Top of Page

fab

1310 Posts

Posted - Oct 11 2011 :  08:56:09  Show Profile  Reply
Hello,
please re-check your code, because version 3.1.2 has DuplicateCompressionInfo method.
Otherwise please post your code.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: