Unfortunately the device knows nothing about each individual group in a report. The best approach for a task like this one would be to create a dynamic query connected to a single report object, then each time the query changes re-generating and re-printing the report.
Actually after messing with it for a while I was able to get it work as long as each group starts on a new page. my test code procedure TForm1.ppGroup1AfterGroupBreak(Sender: TObject); begin fFileDevice.EndJob; ffiledevice.Free; fFileDevice := TppPDFDevice.Create(self); FFileDevice.FileName := zMysqlQuery1.fieldbyname('Account').asstring+'.pdf'; fFileDevice.StartJob; end; procedure TForm1.BitBtn1Click(Sender: TObject); var lPrinterDevice: TppPrinterDevice; begin
Comments
Adding a PrinterDevice to the device list will allow you to print as well as
export once calling PrintToDevice...
uses
ppPrnDev;
procedure TForm1.Button1Click(Sender: TObject);
var
lPrinterDevice: TppPrinterDevice;
begin
lPrinterDevice := TppPrinterDevice.Create(nil);
try
lPrinterDevice.Publisher := ppReport1.Publisher;
FDevice := TppDevice.Create(self);
FDevice.Publisher := ppReport1.Publisher;
FDevice.OnPageReceive := ehDevicePageReceive;
ppReport1.AllowPrintToFile := True;
ppReport1.ShowPrintDialog := False;
ppReport1.PrintToDevices;
FDevice.Free;
finally
lPrinterDevice.Free;
end;
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Can you take it a step further and create a pdf file per Group as we may
have more than one page per group?
Thanks again
Unfortunately the device knows nothing about each individual group in a
report. The best approach for a task like this one would be to create a
dynamic query connected to a single report object, then each time the query
changes re-generating and re-printing the report.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
as each group starts on a new page.
my test code
procedure TForm1.ppGroup1AfterGroupBreak(Sender: TObject);
begin
fFileDevice.EndJob;
ffiledevice.Free;
fFileDevice := TppPDFDevice.Create(self);
FFileDevice.FileName :=
zMysqlQuery1.fieldbyname('Account').asstring+'.pdf';
fFileDevice.StartJob;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
lPrinterDevice: TppPrinterDevice;
begin
lPrinterDevice := TppPrinterDevice.Create(nil);
fFileDevice := TppPDFDevice.Create(self);
FFileDevice.FileName :=
zMysqlQuery1.fieldbyname('Account').asstring+'.pdf';
try
lPrinterDevice.Publisher := ppReport1.Publisher;
FDevice := TppDevice.Create(self);
FDevice.Publisher := ppReport1.Publisher;
FDevice.OnPageReceive := ehDevicePageReceive;
ppReport1.AllowPrintToFile := True;
ppReport1.ShowPrintDialog := False;
ppReport1.PrintToDevices;
FFileDevice.endjob;
FDevice.Free;
finally
lPrinterDevice.Free;
end;
end;
procedure TForm1.ehDevicePageReceive(Sender, aPage: TObject);
var
lPage: TppPage;
begin
lPage := TppPage(aPage);
// lFileDevice := TppPDFDevice.Create(self);
try
if not ffiledevice.Busy then
FFileDevice.StartJob;
fFileDevice.ReceivePage(lPage);
finally
end;
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com