{"title":"TestRequestPage.SaveAsPdf(Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/testrequestpage/testrequestpage-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/testrequestpage/testrequestpage-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/testrequestpage/testrequestpage-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 an Adobe Acrobat (.pdf) file.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"TestRequestPage.SaveAsPdf(Text) Method","slug":"testrequestpagesaveaspdftext-method","at":0,"chars":2021},{"level":2,"title":"Syntax","slug":"syntax","at":221,"chars":63},{"level":2,"title":"Parameters","slug":"parameters","at":284,"chars":249},{"level":2,"title":"Remarks","slug":"remarks","at":533,"chars":287},{"level":2,"title":"Example","slug":"example","at":820,"chars":1058},{"level":2,"title":"Related information","slug":"related-information","at":1878,"chars":143}],"text":"# TestRequestPage.SaveAsPdf(Text) Method\n> Version: _Available or changed with runtime version 1.0._\nSaves a report as an Adobe Acrobat (.pdf) file.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n TestRequestPage.SaveAsPdf(FileName: Text)\n```\n## Parameters\nTestRequestPage\nType: testrequestpage-data-type\nAn instance of the testrequestpage-data-type data type.\nFileName\nType: ../text/text-data-type\nThe path and file name to which the report is saved. The file name extension should be .pdf.\n## Remarks\nAll filters and options that have been set on the TestRequestPage are respected in the saved report.\nAfter you run this method, you cannot continue to interact with the TestRequestPage. If you want to continue to use the TestRequestPage variable, you must run a report again.\n## Example\nThe following example shows the code for a test method to run a report and a request page handler method to test the request page. This example requires that you create the following:\n A test codeunit called SaveAsPDF.\n A test method in the test codeunit called TestSaveAsPDF.\n A handler method of type RequestPageHandler called ReqPageHandler. This handler method has one parameter called RequestPage of Type TestRequestPage and Subtype Customer - Top 10 List. The RequestPage parameter is specified as VAR and is passed by reference to the handler method.\n```al\nvar\n    Filename: Text;\nbegin\n    //Test method: TestSaveAsPDF\n    Filename := TemporaryPath + 'MyRep.pdf';\n    Message(Filename);\n    if not File.Erase(Filename) then\n      Error('Cannot erase %1',Filename);\n    Report.Run(111);\n    if not File.Exists(Filename) then\n      Error('File should exist!');\n\n    //Request Page Handler method\n    RequestPage.Customer.SetFilter(\"No.\", '20000');\n    RequestPage.ChartType.Value('Pie chart');\n    RequestPage.SaveAsPDF(Filename);\nend;\n\n```\n## Related information\ntestrequestpage-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}