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
 Best method to convert (Multipage)Image to PDF
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

swestner

17 Posts

Posted - Apr 24 2012 :  01:55:35  Show Profile  Reply
Hello,

which is the best method to convert a (multipage)-Image to PDF?

At the moment I use:

class procedure TImageSupport.ConvertImageToPDF(infile, outfile: String);
var
i: Integer;
ImageEnMView1: TImageEnMView;
begin
ImageEnMView1:=TImageEnMView.Create(Nil);
try
ImageEnMView1.MIO.LoadFromFile(infile);
for i:=0 to ImageEnMView1.ImageCount-1 do begin
if ImageEnMView1.ImageBitCount[i]=1 then begin
ImageEnMView1.MIO.Params[i].PDF_Compression:=ioPDF_G4FAX;
end
else begin
ImageEnMView1.MIO.Params[i].PDF_Compression:=ioPDF_JPEG;
end;
ImageEnMView1.MIO.Params[i].PDF_PaperWidth:=
Round((ImageEnMView1.MIO.Params[i].Width/ImageEnMView1.MIO.Params[i].DpiX)*72);
ImageEnMView1.MIO.Params[i].PDF_PaperHeight:=
Round((ImageEnMView1.MIO.Params[i].Height/ImageEnMView1.MIO.Params[i].DpiY)*72);
end;
ImageEnMView1.MIO.SaveToFilePDF(outfile);
finally
ImageEnMView1.Free;
end;
end;

But this create a GUI-Element in my service. It works at the moment but it's not fine. Is it possible to create only a TImageEnMIO to do laoding and saving without the TImageIOMView?

Thanks

Stefan

fab

1310 Posts

Posted - Apr 24 2012 :  05:34:04  Show Profile  Reply
Hello,
this code uses only a TImageEnIO and a TIEBitmap component:

var
  filename: string;
  io: TImageEnIO;
  bmp: TIEBitmap;
  i, count: integer;
begin
  filename := 'input.tif';

  bmp := TIEBitmap.Create();
  io := TImageEnIO.CreateFromBitmap(bmp);
  try
    io.CreatePDFFile('c:\out.pdf');
    count := IEGetFileFramesCount(filename);
    for i:=0 to count-1 do
    begin
      io.Params.ImageIndex := i;
      io.LoadFromFile(filename);
      io.SaveToPDF();
    end;
  finally
    io.ClosePDFFile();
    io.Free();
    bmp.Free();
  end;

end;
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: