ImageEnIO has a ClosePDFFile method but ImageEnMIO does not because it calls IEPDFClose. You could try using ImageEnView1.IO.CreatePDFFile, ImageEnView1.IO.LoadFromFile, ImageEnView1.IO.SaveToPDF and ImageEnView1.IO.ClosePDFFile to see it resolves your problem. Also see the demo for this.
ImageEnView1.IO.CreatePDFFile( 'D:\output.pdf' );
// load and save page 1
ImageEnView1.IO.LoadFromFile('C:\page1.tiff');
ImageEnView1.IO.Params.PDF_Compression := ioPDF_G4FAX; // G4Fax compression
ImageEnView1.IO.SaveToPDF;
// load and save page 2
ImageEnView1.IO.LoadFromFile('C:\page2.tiff');
ImageEnView1.IO.Params.PDF_Compression := ioPDF_G4FAX; // G4Fax compression
ImageEnView1.IO.SaveToPDF;
...Other pages...
// close PDF file
ImageEnView1.IO.ClosePDFFile;
ImageEnMIO calls IEPDFClose:
procedure TImageEnMIO.SaveToStreamPDF(Stream: TStream; SelectedOnly : boolean = false);
var
Param: TIOParams;
Progress: TProgressRec;
bmp: TIEBitmap;
NullProgress: TProgressRec;
han: pointer;
imgCount: integer;
procedure _SaveImg(ImgIdx, FileIdx: integer);
begin
Param := fParamsList.Params[ImgIdx];
if FileIdx = 0 then
han := IEPDFCreate(Param);
Attached_CopyToIEBitmap( ImgIdx, bmp );
bmp.DefaultDitherMethod := fDefaultDitherMethod;
IEPDFSave(han, bmp, Param, NullProgress);
with Progress do
if assigned(fOnProgress) then
fOnProgress(Sender, trunc(per1 * FileIdx));
end;
var
i: integer;
begin
try
fAborting := False;
if not IsAttached() then
exit;
if SelectedOnly and assigned( fImageEnMView ) then
imgCount := (fImageEnMView as TImageEnMView).MultiSelectedImagesCount
else
imgCount := GetIEMBitmap.Count;
if imgCount = 0 then
exit;
Progress := ProgressRec( Self, fOnProgress, fAborting );
NullProgress := NullProgressRec( Progress.Aborting );
Progress.per1 := 100 / imgCount;
bmp := TIEBitmap.Create;
han := nil;
i := 0;
while not fAborting and (i < imgCount) do
begin
if SelectedOnly and assigned( fImageEnMView ) then
_SaveImg((fImageEnMView as TImageEnMView).MultiSelectedImages[i], i)
else
_SaveImg(i, i);
inc(i);
end;
if imgCount > 0 then
Param := fParamsList.Params[0];
IEPDFClose(han, Stream, Param);
FreeAndNil(bmp);
finally
DoFinishWork;
end;
end;
{$endif}
{!!
<FS>TImageEnMIO.SaveToFilePDF
<FM>Declaration<FC>
procedure SaveToFilePDF(const FileName: string; SelectedOnly: Boolean = False);
<FM>Description<FN>
Creates a multipage Adobe PDF file with all images in the attached <A TImageEnMView> or <A TIEMultiBitmap>.
If <FC>SelectedOnly<FN> = True and the component is attached to a <A TImageEnMView> then only the selected images are output.
Note: If an internal save error is encountered <A TImageEnMIO.Aborting> will return true. Saving issues due to insufficient write permissions and disk write failures will raise an exception.
<FM>Example<FC>
// load a multipage TIFF and save it as a PDF file
ImageEnMView.MIO.LoadFromFile('C:\multipage.tiff');
ImageEnMView.MIO.SaveToFilePDF('D:\output.pdf');
!!}
{$ifdef IEINCLUDEPDFWRITING}
procedure TImageEnMIO.SaveToFilePDF(const FileName: string; SelectedOnly: Boolean = False);
var
fs: TFileStream;
begin
fAborting := False;
fs := TFileStream.Create(FileName, fmCreate);
try
SaveToStreamPDF(fs, SelectedOnly);
finally
FreeAndNil(fs);
end;
end;
{$endif}
Nigel may have other ideas or comments.
Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development