Saves a report as a .pdf file.
[Ok :=] REPORT.SAVEASPDF(Number, FileName[, Record]) [Ok :=] ReportVariable.SAVEASPDF(FileName)
- Type: Integer The ID of the report that you want to run. From the C/AL Editor, on the View menu, choose C/AL Symbol Menu to select the report from a list.
- Type: Text The path and name of the file that you want to save the report as.
- Type: Record Specifies which record to use in the report. Any filters that have been applied to the record that you specify will be used.
- The report that you want to run.
Property Value/Return Value
true if the report was saved; otherwise, false.
If you omit this optional return value, then run-time errors can occur. If you include a return value, it is assumed that you will handle any errors.
You can use the SAVEASPDF function 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 function.
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 Microsoft Dynamics NAV Server. If you call this function from a client, such as from an action on a page, then use the DOWNLOAD Function (File) to download the .pdf file from the computer that is running Microsoft Dynamics NAV Server to the computer that is running the client.
This example shows how to use the SAVEASPDF function to save a specific report as a PDF file on the computer that is running Microsoft Dynamics NAV Server. It requires that you create the following variables.
Sales - Invoice
Filename := 'C:\MyReports\report206.pdf'; ReturnValue := Report206.SAVEASPDF(Filename);