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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Extract Jpegs to PDF - what am I doing wrong.

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jalbrecht Posted - Dec 16 2024 : 16:45:30
Hello,

I am trying to put jpgs into a PDF file.
I have tried many diffrent options. With or without PDFium.
PDFium always give me a exception that I can not monitor, so I came up with :

   IEVx := tImageEnView.Create(JvXPContainer8);
   IEVx.IO.CreatePDFFile(OutputFileName);
   for p:=0 to  TheList.Count-1 do
   begin
       IEVx.IO.Params.PDF_PaperSize := iepA4;
       IEVx.IO.Params.Dpi := 90;
       IEVx.IO.params.PDF_ImageOptions := [iepioShrinkOnly, iepioCentered];
       IEVx.IO.Params.PDF_Compression := ioPDF_JPEG ;
       IEVx.IO.Params.BitsPerSample   := 2;
       IEVx.IO.Params.SamplesPerPixel := 3;
       IEVx.IO.LoadFromFile(TheList[p]);

       if IEVx.IEBitmap_Width > IEVx.IEBitmap_Height then
          IEVx.IO.Params.PDF_PaperLayout := ielLandscape
       else
          IEVx.IO.Params.PDF_PaperLayout := ielPortrait;
       IEVx.Update();
       IEVx.IO.SaveToPDF;
   end;
   IEVx.IO.ClosePDFFile;
   IEVx.Free;

TheList containg full path to jpegs.
As a result I get an enormous PDF file (24 Mb for 13 pages).
All the page in it are close to the letter format 8,26 x 11,69 inches.

My jpegs are A4 digitized page 600 dpi, 4959 x 7031 pixels.
Some are in protrait some in landscape that why I am turning some.
If I don't I get a big page with a white bottom.

What am I missing and why the pages, thus the size of the PDF, is not shrunk to A4 ?

Many thanks in advance.

//------------------------------------------
Other tried way #1 :

IECreatePDFFromFileList(OutputFileName, TheList, iepA4 , ioPDF_JPEG , 'CHECKS_NUMBER', NOMUSER); 

Using the same list as above.
Fires an exception everytime wheter I use PDFium or not.

//------------------------------------------
Other tried way #2 :

       IevS := IEVisionLib.createSearchablePDFGenerator(PAnsiChar(AnsiString(langPath)), PAnsiChar(AnsiString(langCode)) );
       IevS.beginDocument( PWideChar( OutputFileName ), PAnsiChar(AnsiString(RvRenderPDF1.DocInfo.KeyWords )));
       Iev := TImageEnMView.Create(self);
       udm1.fi_img.first;
       while not udm1.fi_img.eof  do
       begin
             if fileexists(udm1.fi_img.fieldbyname('CHEMIN_CPL').AsString) then
             begin
                 Iev.MIO.LoadFromFileAuto(udm1.fi_img.fieldbyname('CHEMIN_CPL').AsString);
                 Application.ProcessMessages;
                 IEBitmap := Iev.IEBitmap.GetIEVisionImage();
                 IevS.addPage(IEBitmap, ievPDFImgFmt_JPEG) ;
                 Iev.clear;
              end;
              udm1.fi_img.next;
        end;
        IevS.endDocument();

//------------------------------------------ >
Same size of pages but 10 times longer because of the OCR.



4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Dec 18 2024 : 20:07:31
What PDF engine are you using?

http://www.imageen.com/help/TIEGlobalSettings.ActivePDFEngine.html

Ensure you set:

IEGlobalSettings().PDFEngine := ieenNative;



Nigel
Xequte Software
www.imageen.com
jalbrecht Posted - Dec 18 2024 : 03:27:39
Hi,

thanks for your replies.

First I tried :

                            p := 0;
                            udm1.fi_img.first;
                            TheList := TStringlist.Create;
                            while not udm1.fi_img.eof  do
                            begin
                               TheList.Add( udm1.fi_img.fieldbyname('CHEMIN_CPL').AsString );
                               udm1.fi_img.next;
                            end;
                            try
                               IEVx := tImageEnView.Create(JvXPContainer8);
                               IEVx.IO.CreatePDFFile(OutputFileName);
                               JvProgressBar1.Max := TheList.Count;
                               for p:=0 to  TheList.Count-1 do
                               begin
                                   IEVx.IO.LoadFromFile(TheList[p]);
                                   if IEVx.IEBitmap_Width > IEVx.IEBitmap_Height then
                                   begin
                                      IEVx.IO.Params.PDF_PaperLayout := ielLandscape;
                                      IEVx.Bitmap.IEResample( 1785, 2526, rfLanczos3, True );
                                   end
                                   else
                                   begin
                                      IEVx.IO.Params.PDF_PaperLayout := ielPortrait;
                                      IEVx.Bitmap.IEResample( 2526, 1785,  rfLanczos3, True );
                                   end;
                                   IEVx.IO.SaveToPDF;
                                   cxLabel6.Caption := 'Pages for the document: '+inttostr(p+1)+' / '+inttostr(JvProgressBar1.Max);
                                   JvProgressBar1.Position := p;
                                   application.ProcessMessages;
                               end;
                               IEVx.IO.ClosePDFFile;
                               IEVx.Free;
                            except
                                  on e:Exception do
                                  begin
                                    showmessage(e.message);
                                  end;
                            end;
                            TheList.Free;

I get a file of 168Mb for 26 pages.
Pages are 8,26 x 11,69 inches.

Then I tried to download last version of iePDF and I got :

IECreatePDFFromFileList(OutputFileName+'2', TheList, iepA4 , ioPDF_JPEG , cxGrid1DBTableView1.DataController.DataSource.DataSet.FieldByName('CHECKS_NUMBER').Asstring, NOMUSER);
Now it workls and I have a file of 48 mb for the same 26 pages.
Pages are the same sizes

Best regards.

xequte Posted - Dec 17 2024 : 20:04:00
Also I cannot reproduce your issue with the IECreatePDFFromFileList helper method. This works fine for me:

procedure TForm1.Button1Click(Sender: TObject);
const
  OutputFileName = 'D:\MyNewPDF3.pdf';
  NOMUSER = 'Xequte Software';
var
  TheList: TStringList;
begin
  TheList := TStringList.Create();
  TheList.Add( 'D:\im.jpg' );
  TheList.Add( 'D:\im2.jpg' );
  TheList.Add( 'D:\im3.jpg' );
  if IECreatePDFFromFileList(OutputFileName, TheList, iepA4 , ioPDF_JPEG , 'CHECKS_NUMBER', NOMUSER, 72, True, True ) = False then
    raise Exception.create( 'Cannot create PDF' );
  TheList.Free();
end;


Nigel
Xequte Software
www.imageen.com
xequte Posted - Dec 17 2024 : 18:40:37
Hi

Setting the PDF page size only instructs the viewing application what size to display or print the page. It does not affect file size.

To reduce the size of a PDF file you need to:

- Change your PDF compression (ioPDF_JPEG which you are using is usually best if it contains color images)

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

- Reduce the size of the images it contains:

https://www.imageen.com/help/TIEBitmap.Resample.html


Your images are huge so your PDF page will be a similar size (the total combined size of all your images). You should scale them to a more reasonable size, e.g. if you are saving to A4 and assume a maximum zoom of 300% then a maximum size of 1785x2526 (A4=595x842 * 3.0) should be plenty.



Nigel
Xequte Software
www.imageen.com