{"title":"Report.SaveAsPdf(Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/report/reportinstance-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/reportinstance-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/reportinstance-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(Text) Method","slug":"reportsaveaspdftext-method","at":0,"chars":3480},{"level":2,"title":"Syntax","slug":"syntax","at":195,"chars":63},{"level":2,"title":"Parameters","slug":"parameters","at":258,"chars":196},{"level":2,"title":"Return Value","slug":"return-value","at":454,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":692,"chars":2042},{"level":3,"title":"Error conditions","slug":"error-conditions","at":1922,"chars":812},{"level":2,"title":"Example","slug":"example","at":2734,"chars":612},{"level":2,"title":"Related information","slug":"related-information","at":3346,"chars":134}],"text":"# Report.SaveAsPdf(Text) 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(FileName: Text)\n```\n## Parameters\nReport\nType: report-data-type\nAn instance of the report-data-type data type.\nFileName\nType: ../text/text-data-type\nThe path and name of the file that you want to save the report as.\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\nThe SaveAsPdf method can be used on the Report data type and on Report variables. When you are programming the SaveAsPdf method, if you do not know the specific report that you want to run, then use the static version of the SaveAsPdf method, see Report.SaveAsPdf(Integer, Text [, var Record])<report-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 three ways:\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 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];\n    MyReportInstance: Report::MyReport\nbegin\n    // setup that FileNameAndPath is valid to write to\n\n    MyReportInstance.SaveAsPdf(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>"}