{"title":"Report.SaveAsPdf(Integer, Text [, var Record]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/report/report-saveaspdf-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/report/report-saveaspdf-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/report/report-saveaspdf-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Saves a report as a .pdf file.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Report.SaveAsPdf(Integer, Text [, var Record]) Method","slug":"reportsaveaspdfinteger-text-var-record-method","at":0,"chars":4034},{"level":2,"title":"Syntax","slug":"syntax","at":219,"chars":103},{"level":2,"title":"Parameters","slug":"parameters","at":322,"chars":382},{"level":2,"title":"Return Value","slug":"return-value","at":704,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":942,"chars":2273},{"level":3,"title":"Error conditions","slug":"error-conditions","at":2267,"chars":948},{"level":2,"title":"Example","slug":"example","at":3215,"chars":685},{"level":2,"title":"Related information","slug":"related-information","at":3900,"chars":134}],"text":"# Report.SaveAsPdf(Integer, Text [, var Record]) Method\n> Version: _Available or changed with runtime version 1.0._\nSaves a report as a .pdf file.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n[Ok := ]  Report.SaveAsPdf(Number: Integer, FileName: Text [, var Record: Record])\n```\n## Parameters\nNumber\nType: ../integer/integer-data-type\nThe ID of the report that you want to run.\nFileName\nType: ../text/text-data-type\nThe path and name of the file that you want to save the report as.\n*[Optional] Record*\nType: ../record/record-data-type\nSpecifies which record to use in the report. Any filters that have been applied to the record that you specify will be used.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue 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.\n## Remarks\nYou can use the SaveAsPdf method on the global Report object and on instances of a Report variable.\nIf, at design time, you do not know the specific report that you want to run, then use this method (the static one) and specify the report object ID in the Number parameter. If you do know which report you want to run, then use the instance method Report.SaveAsPdf(FileName: Text)<reportinstance-saveaspdf-method>.\nWhen you call SaveAsPDF, the report is generated and saved to the file specified in \"FileName.\" A Saving to PDF window shows the status of the process. Note that the request page will not be shown.\n> NOTE\n> The FileName parameter specifies a location on the computer that is running Business Central. If you call this method from a client, such as from an action on a page, then use the ../file/file-download-method method to download the .pdf file from the computer that is running the Business Central server to the computer that is running the client.\n> NOTE\n> 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 Business Central instance configuration or changing the PDFFontEmbedding property in report objects.\n### Error conditions\nThe method can fail in the following four ways:\n If no report exists with an object id as specified in \"Number\".\n If the destination folder specified in FileName does not exist,\n If the file specified in FileName is being used, or\n If the Business Central server process does not have permission to write to the file specified in FileName.\nIf the report you specify does not exist, then a run-time error occurs.\nIf the destination folder that you specify in FileName does not exist, then you get the following error: The specified path is invalid.\nIf the file that you specify in FileName is being used, then you get the following error: An I/O exception occurred during the operation.\nIf the Business Central server process does not have permission to write to the file that you specify in FileName, then you get the following error: Either the caller does not have the required permission or the specified path is read-only.\n## Example\nThis example shows how to use the static SaveAsPdf method in a safe way (where no errors occur).\n```al\nvar\n    FileNameAndPath: Text[250];\nbegin\n    // setup that FileNameAndPath is valid to write to\n\n    // Note that by using the scope operator (::), you catch at compile time if MyReport does not exist\n    Report.SaveAsPdf(Report::MyReport, FileNameAndPath);\nend;\n```\nFor a full example that shows how to use any of the Report.SaveAs* methods (SaveAsExcel, SaveAsHtml, SaveAsPDF, SaveAsWord, or SaveAsXML) to generate the report in the Business Central server and then write the report output to a file, see Report.SaveAsExcel(FileName: Text)<report-saveasexcel-method>.\n## Related information\nreport-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}