[Event Request] Table 77 Report Selection, SaveReportAsPDF
Please add the following event to table object 77 Report Selection function SaveReportAsPDF(). This would help to merge stationery or add additional pdfs (e.g. general terms) to the created files.
An useful signature would be ReportID, RecordVariant, FilePath.
LOCAL SaveReportAsPDF(ReportID : Integer;RecordVariant : Variant;LayoutCode : Code[20]) FilePath : Text[250]
FilePath := COPYSTR(FileMgt.ServerTempFileName('pdf'),1,250);
ReportLayoutSelection.SetTempLayoutSelected(LayoutCode);
REPORT.SAVEASPDF(ReportID,FilePath,RecordVariant);
ReportLayoutSelection.SetTempLayoutSelected('');
COMMIT;
// ---New Code Begin---
OnAfterSaveReportAsPdf(ReportID, RecordVariant, FilePath);
// ---New Code End---
Thank you.
File usage is not allowed in the cloud. Would an event that passes the Stream with the PDF work instead?
Well, that's a good question. The problem is, that I want to use the created pdf file. I can handle streams, that's not the problem, but SAVEASPDF at this point will create a file, isn't it?
Is there any way to get the stream instead of the pdf file to apply stationery paper?
The problem is really simple. Some of my customers are using printers with stationery paper tray. But if the use the Mail / Send method they would like to have stationery paper, even if the RDLC report don't have. Of course, I could set multiple layouts for my report, but it would be much easier to apply a stationery paper at the created pdf file.
Try to subscribe to the existing event COD9651.OnBeforeMergeDocument(..) that is called by all system SAVEAS... methods. There are parameters that seems to be enough for what you want to do:
- ReportID : integer,
- ReportAction : 'SaveAsPdf,SaveAsWord,SaveAsExcel,Preview,Print,SaveAsHtml'
- InStrXmlData : instream
- OutStream : outstream
You subscribe, do your changes to InStrXmlData and then
COPYSTREAM(OutStream,InStrXmlData);
Handled := TRUE;
on return from event this file will be exported, if OutStream has some value and file name is not blank.
Or you override the existing functionality by exporting all needed files in your subscriber, leaving OutStream blank, and setting Handled := TRUE;
Yeah, I tried and it worked! Thanks a lot. Well, I needed to do some changes in my service to attach the stationery paper, but it worked.