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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
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; |