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
 Multiple TIFF files to PDF

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
nantunes1974 Posted - Nov 29 2015 : 11:38:32
Hi all,

I am trying to convert multiple tif files (multi-page) to pdf. From the seventh file, with about 180KB, all PDF have all pages in tif file but only blank pages.
I appreciate any help, please.
Many thanks in advance.

The code i am using is:

function T_Entrega.RenFilesToPDF(const StartDir: String): Boolean;
var
  sr: TSearchRec;
  Res: Integer;
  _page : SmallInt;
begin
  Res := FindFirst(BackSlash(StartDir) + '*.tif', faAnyfile, sr );

  if Res = 0 then

  try
    while res = 0 do begin
      if (sr.Attr and faDirectory <> faDirectory) then

        with ImageEnView1.IO do begin

          Params.PDF_PaperSize := IEStrToPaperSize('A4', iepA4);
          Params.PDF_Compression := ioPDF_G4FAX;

          CreatePDFFile(BackSlash(DirLotesDest) + ChangeFileExt(sr.name, '.pdf'));

          ImageEnView1.Blank;
          LoadFromFile(BackSlash(DirLotesDest) + sr.Name);

          for _page := 0 to Params.TIFF_ImageCount - 1 do begin
            Params.TIFF_ImageIndex := _page;
            SaveToPDF;
          end;

          ClosePDFFile;
        end;

      ImageEnView1.ClearAll;
      Res := FindNext(sr);

  end;
  finally
    FindClose(sr)
  end;
  Result := True;
end;

2   L A T E S T    R E P L I E S    (Newest First)
nantunes1974 Posted - Dec 03 2015 : 05:15:07
Many thanks, Nigel.
It works fine.
xequte Posted - Dec 02 2015 : 18:32:48
Hi

There is an issue in your code. When you want another page of a TIFF you need to set TIFF_ImageIndex and then call LoadFromFile() again.


function TForm1.RenFilesToPDF(const StartDir: String): Boolean;
var
  sr: TSearchRec;
  Res: Integer;
  _page : SmallInt;
begin
  Result := False;
  Res := FindFirst( StartDir + '*.tif', faAnyfile, sr );

  if Res = 0 then
  try
    while res = 0 do
    begin
      if (sr.Attr and faDirectory <> faDirectory) then
        with ImageEnView1.IO do
        begin
          Params.PDF_PaperSize := IEStrToPaperSize('A4', iepA4);
          Params.PDF_Compression := ioPDF_G4FAX;

          CreatePDFFile( StartDir + ChangeFileExt(sr.name, '.pdf'));

          ImageEnView1.Blank;

          // Reset index to load
          Params.TIFF_ImageIndex := 0;
          LoadFromFile( StartDir + sr.Name);

          for _page := 0 to Params.TIFF_ImageCount - 1 do
          begin
            Params.TIFF_ImageIndex := _page;
            // Need to reload if we changed the index
            if _page > 0 then
              LoadFromFile( StartDir + sr.Name);
            SaveToPDF;
          end;

          ClosePDFFile;
          Result := True;
        end;

      ImageEnView1.ClearAll;
      Res := FindNext(sr);
    end;
  finally
    FindClose(sr)
  end;
end;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com