Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
swestner
Posted - Apr 24 2012 : 01:55:35 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
1 L A T E S T R E P L I E S (Newest First)
fab
Posted - Apr 24 2012 : 05:34:04 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;