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
 GenerateSearchablePDF creates very large PDF's for JPEG images
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

kevingmcb

Canada
3 Posts

Posted - Apr 05 2024 :  15:58:50  Show Profile  Reply
I am using the GenerateSearchablePDF demo with IEVision 8.1.0 and when generating a PDF from two JPEG files (about 500K each) the resulting PDF is around 20meg (about 10 meg. per page). If I use the PDF Optimizer tool in Acrobat to apply JPEG compression to the images in the PDF (without downsampling) the file size is reduced by a factor of 20 approx., resulting in a PDF of around 1 meg.

I tried modifying the demo to add the JPEG image format parameter to the pdfGen.addPage call as follows:

pdfGen.addPage(ImageEnMView1.IEBitmap.GetIEVisionImage(),ievPDFImgFmt_JPEG);

However the resulting PDF is empty. Is there any way to apply JPEG compression to the images so that the resulting PDF is not so large?

Thanks.



Kevin McB

xequte

38653 Posts

Posted - Apr 05 2024 :  16:13:31  Show Profile  Reply
Hi Kevin

Firstly, can you confirm what version of ImageEn you are using. Prior to v13, ImageEn did not explicitly check whether images had a transparency. If you enabled the alpha channel, even if it was not used, it made the PDF much larger because the images needed to be output with the alpha channel (which is not JPEG compressed).

Secondly, please specify the PDF image compression as JPEG using:

http://www.imageen.com/help/TIOParams.PDF_Compression.html


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

kevingmcb

Canada
3 Posts

Posted - Apr 06 2024 :  12:15:04  Show Profile  Reply
Hi Nigel,

I am using ImageEn 13.1.0 and IEVision 8.1.0 with Delphi 12 Athens.

I modified the GenerateSearchablePDF demo to apply the JPG compression and remove any alpha channel, as follows, but the resulting PDF is still about 10 meg. per page:


// generate PDF
    pdfGen := IEVisionLib.createSearchablePDFGenerator(PAnsiChar(AnsiString(langPath)), PAnsiChar(AnsiString(langCode)) );
    pdfGen.setSegmentationMode(TIEVisionOCRPageSegmentationMode(cmbLayout.ItemIndex));
    pdfGen.beginDocument(PAnsiChar(AnsiString( outFile )), PAnsiChar(AnsiString( 'IEVision PDF Test' )));
    for i := 0 to ImageEnMView1.ImageCount - 1 do
    begin
      ProgressBar1.Position := MulDiv( i, 100, ImageEnMView1.ImageCount );
      ProgressBar1.Visible  := True;

      ImageEnMView1.SelectedImage := i;
      Application.ProcessMessages();
      ImageEnMView1.IEBitmap.ParamsEnabled := true;
      ImageEnMView1.IEBitmap.Params.Dpi := ImageEnMView1.MIO.Params[i].Dpi;
      // added to set compression and remove alpha channel from JPEG images
      if ( CompareText( ExtractFileExt( ImageEnMView1.MIO.Params[i].FileName ), '.jpg' ) = 0 ) 
      or ( CompareText( ExtractFileExt( ImageEnMView1.MIO.Params[i].FileName ), '.jpeg' ) = 0 ) then
      begin
        ImageEnMView1.IEBitmap.Params.PDF_Compression := ioPDF_JPEG;
        ImageEnMView1.IEBitmap.Params.JPEG_Quality    := 90;
        if ImageEnMView1.IEBitmap.HasAlphaChannel() then
          ImageEnMView1.IEBitmap.RemoveAlphaChannel( true );
        ImageEnMView1.Update;
      end;
      //
      pdfGen.addPage(ImageEnMView1.IEBitmap.GetIEVisionImage());
    end;
    pdfGen.endDocument();
    pdfGen := nil;


Is there something I'm missing?

Thanks



Kevin McB
Go to Top of Page

xequte

38653 Posts

Posted - Apr 06 2024 :  18:28:24  Show Profile  Reply
Sorry Kevin,

I misread your original message

I thought you were using the native PDF generator (http://www.imageen.com/help/TIEPDFBuilder.html), but as you actually stated you are using IEVision's GenerateSearchablePDF method.

In that case, TIOParams.PDF_Compression is not relevant, and ievPDFImgFmt_JPEG is the correct method to output with JPEG compression, rather than the default FLATE.

In testing the code, I can confirm that there is something unexpected happening when ievPDFImgFmt_JPEG is specified, so I've passed that onto my partner to investigate.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38653 Posts

Posted - Apr 15 2024 :  23:01:17  Show Profile  Reply
Hi Kevin

We'll a fix for the JPEG output issue in the upcoming release.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

kevingmcb

Canada
3 Posts

Posted - Apr 16 2024 :  15:21:57  Show Profile  Reply
Thanks Nigel! Any time frame for the next update?

Kevin McB
Go to Top of Page

xequte

38653 Posts

Posted - Apr 16 2024 :  18:24:49  Show Profile  Reply
Hi Kevin

We're aiming for later in April.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: