Report.SaveAsPdf(Integer, Text [, var Record]) Method
Version: Available or changed with runtime version 1.0.
Saves a report as a .pdf file.
This method is supported only in Business Central on-premises.
[Ok := ] Report.SaveAsPdf(Number: Integer, FileName: Text [, var Record: Record])
The ID of the report that you want to run.
The path and name of the file that you want to save the report as.
Specifies which record to use in the report. Any filters that have been applied to the record that you specify will be used.
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
You can use the SaveAsPDF method on the global Report object or on Report variables. If, at design time, you do not know the specific report that you want to run, then use the global Report object and specify the report number in the Number parameter. If you do know which report you want to run, then create a Report variable, set the Subtype of the variable to a specific report, and use this variable when you call the SaveAsPDF method.
When you call SaveAsPDF, the report is generated and saved to "FileName." A Saving to PDF window shows the status of the process. Note that the request page will not be shown.
The FileName parameter specifies a location on the computer that is running Dynamics 365 Business Central service. If you call this method from a client, such as from an action on a page, then use the DOWNLOAD Method (File) to download the .pdf file from the computer that is running Dynamics 365 Business Central service to the computer that is running the client.
By default, when a report uses an RDLC report layout at runtime, fonts are embedded in the generated PDF. You can specify whether fonts are embedded in the PDF for RDLC reports by changing the Report PDF Font Embedding setting in the Dynamics 365 Business Central service instance configuration or changing the PDFFontEmbedding property in report objects.
This example shows how to use the SaveAsPDF method to save a specific report as a PDF file on the computer that is running Dynamics 365 Business Central service.
var Filename: Text; ReturnValue: Boolean; Report206: Report " Sales - Invoice"; begin Filename := 'C:\MyReports\report206.pdf'; ReturnValue := Report206.SaveAsPDF(Filename); end;