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
 JPEG Conversion to PDF file size explodes
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

brandonbrown

USA
37 Posts

Posted - Feb 04 2021 :  12:31:38  Show Profile  Reply
Hi there all,

I read through other posts about version 8 and the alpha channel, tried that code, without success so far.

My basic need is I'm taking graphic image files coming in, TIFF, JPEG, and making them PDF files.

For JPEG, for instance, I have 1.7mb scanned form, color, and when I do the basics below, the file size is 23mb.

Code:
multi.ImageList.LoadImages(SOURCE & strFile)

' Test, save immediately as another JPEG
multi.ImageList.CopyTo(0, outputPDF.Image)

outputPDF.Image.SaveImage(SOURCE & "newjpg.jpg")
outputPDF.Image.Resample(outputPDF.Image.Width, outputPDF.Image.Height, HiComponents.IEvolution.IEResampleFilter.FastLinear)
'outputPDF.Image.IOParams.PDF_Compression = HiComponents.IEvolution.IOParams.PDFCompression.JPEG
outputPDF.Image.RemoveAlphaChannel()

outputPDF.Image.CreatePDFFile(SOURCE & "newPDF.PDF")
outputPDF.Image.SaveToPDF()
outputPDF.Image.ClosePDFFile()

I basically immediately save it as another JPEG, and the file size is essentially the same. When I save to PDF, it blows up.

I removed the alpha channel, tried the IOParams line, but when I did that, the file is not a valid PDF and is 1k.

I must be not doing or doing something incorrectly.

Thoughts?

xequte

38682 Posts

Posted - Feb 04 2021 :  18:09:58  Show Profile  Reply
Hi

Is your image monochrome (IOParams.BitsPerSample and IOParams.SamplesPerPixel = 1)?

If so, and you specify compression as ioPDF_JPEG, it will be set to ioPDF_G3FAX2D.

Also, this line does not appear to be doing anything (resampling to same size):

outputPDF.Image.Resample(outputPDF.Image.Width, outputPDF.Image.Height, HiComponents.IEvolution.IEResampleFilter.FastLinear)

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

brandonbrown

USA
37 Posts

Posted - Feb 05 2021 :  14:37:52  Show Profile  Reply
No, it's color. Saving immediately to JPEG works as expected. Adding it to a PDF is when it blows up in size. Is there a sample of adding a JPEG to a PDF?
Go to Top of Page

xequte

38682 Posts

Posted - Feb 05 2021 :  20:48:20  Show Profile  Reply
Your code looks correct above for adding a JPEG to a PDF.

What are your values for PDF_PaperWidth and PDF_PaperHeight?

https://www.imageen.com/ievolutionhelp/html/fbfd7377-250c-1931-46a6-200761a30d21.htm
https://www.imageen.com/ievolutionhelp/html/5de0d52a-a96b-9c8b-b89c-75d61d75bbb2.htm

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