Despite many years using ImageEn I have not tried to load pdf images. Having said that, I cannot get the number of images in a pdf file:
// Read the count of the images in a file
function GetPDFPageCount(const AFileName: String): Integer;
var
iImageEnIO: TImageEnIO;
iPages: Integer;
begin
Result := -1;
iImageEnIO := TImageEnIO.Create(nil);
iImageEnIO.ParamsFromFile(AFileName);
iPages := iImageEnIO.Params.ImageCount;
Result := iPages;
iImageEnIO.Free;
end;
GetPDFPageCount returns a value of 1 with a pdf file that has 6 images.
If I substitute a value of 6 for the GetPDFPageCount function the file loads all the frames successfully into TImageEnMView.
procedure TForm1.Open1Click(Sender: TObject);
var
i: Integer;
iPageCount: Integer;
iFilename: string;
begin
if OpenPictureDialog1.Execute then
begin
if TIEMiscPluginsImageMagick.IsAvailable then
begin
ImageEnMView1.Clear;
iFilename := OpenPictureDialog1.FileName;
if FileExists(iFilename) then
begin
iPageCount := GetPDFPageCount(iFilename);
for i := 0 to iPageCount - 1 do
ImageEnMView1.AppendImage(iFilename + IEM_Path_Index_Delimiter +
IntToStr(i));
ImageEnView1.IO.Params.ImageIndex := 1;
ImageEnView1.IO.Params.Dict.Insert('PDF:Density', 200);
ImageEnView1.IO.LoadFromFile(iFilename);
ImageEnView1.Fit;
Caption := 'PDF- ' + iFilename;
StatusBar1.Panels[0].Text := ExtractFileDir(iFilename);
StatusBar1.Panels[1].Text := ExtractFileName(iFilename);
StatusBar1.Panels[2].Text := IntToStr(iPageCount);
end;
end
else
begin
MessageBox(0, 'Failed to load ImageMagick plugin.', 'Warning',
MB_ICONWARNING or MB_OK);
end;
end;
end;
I found a small dll that is supposed to do this but I cannot get it to function.
attach/w2m/20161214131651_pdfpagecount.zip
58.42 KB
http://www.angusj.com/delphitips/pdfpagecount.php
Is there a way to do this?
Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development