Question
“How can I control the exported image file names?”
Solution
This example shows how to use the device’s OnPageReceive event to control the image file names.
Download: ImageDeviceCustomFileNames.zip
Sample Delphi Code:
uses
ppDevice,
ppFileUtils,
ppImageDevice;
procedure TForm1.ppReport1FileDeviceCreate(Sender: TObject);
begin
// attach handler to page receive event
if (ppReport1.FileDevice is TppImageDevice) then
ppReport1.FileDevice.OnPageReceive := ehFileDevice_PageReceive;
end;
procedure TForm1.ehFileDevice_PageReceive(Sender, aPage: TObject);
var
lsCustomFileName: String;
begin
// assign custom image file name
if (ppReport1.FileDevice is TppImageDevice) then
begin
// example: CustomName_1.jpg, CustomName_2.jpg, ...
lsCustomFileName := 'CustomName_' + IntToStr(TppPage(aPage).PageNo) + '.' +
ppReport1.FileDevice.DefaultExt;
TppImageDevice(ppReport1.FileDevice).ImageFileName := TppFileUtils.GetApplicationFilePath +
lsCustomFileName;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ppReport1.TextFileName := TppFileUtils.GetApplicationFilePath + 'myReport.jpg';
ppReport1.Print;
end;