Question
“Is it possible to create a new PDF file for each page in the report?”
Solution
This can be done by manually taking control of the StartJob/EndJob routines of the TppDevice. Start by creating a generic TppDevice object, assigning its OnPageReceive event and calling PrintToDevices. Next implement the OnPageReceive event to create a PDF Device, start a new job, send the page, and end the job. This will fire for each page of the report effectively creating a new PDF file for each page.
Download: SendEachPageAsNewPDFFile.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 |
uses ppDevice, ppPDFDevice; procedure TForm1.Button1Click(Sender: TObject); begin FDevice := TppDevice.Create(self); FDevice.Publisher := ppReport1.Publisher; FDevice.OnPageReceive := ehDevicePageReceive; ppReport1.AllowPrintToFile := true; ppReport1.PrintToDevices; FDevice.Free; end; procedure TForm1.ehDevicePageReceive(Sender, aPage: TObject); var lPage: TppPage; lFileDevice: TppPDFDevice; begin lPage := TppPage(aPage); lFileDevice := TppPDFDevice.Create(self); try lFileDevice.FileName := 'c:\'+IntToStr(lPage.AbsolutePageNo)+'.pdf'; lFileDevice.StartJob; lFileDevice.ReceivePage(lPage); lFileDevice.EndJob; finally lFileDevice.Free; end; end; |