{"title":"File.View(Text [, Boolean]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-view-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/file/file-view-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/file/file-view-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":"Opens a file from server computer on the client computer in preview mode.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"File.View(Text [, Boolean]) Method","slug":"fileviewtext-boolean-method","at":0,"chars":2510},{"level":2,"title":"Syntax","slug":"syntax","at":338,"chars":166},{"level":2,"title":"Parameters","slug":"parameters","at":504,"chars":286},{"level":2,"title":"Return Value","slug":"return-value","at":790,"chars":245},{"level":2,"title":"Remarks","slug":"remarks","at":1035,"chars":137},{"level":2,"title":"Example","slug":"example","at":1172,"chars":1202},{"level":2,"title":"Related information","slug":"related-information","at":2374,"chars":136}],"text":"# File.View(Text [, Boolean]) Method\n> Version: _Available or changed with runtime version 15.0._\nOpens a file from server computer on the client computer in preview mode. The client computer is the computer that is running the browser that accesses the web client.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n[Ok := ]  File.View(FromFile: Text [, AllowDownloadAndPrint: Boolean])\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nFromFile\nType: ../text/text-data-type\nThe name of the file on the server that you want to preview on the client computer.\n*[Optional] AllowDownloadAndPrint*\nType: ../boolean/boolean-data-type\nWhether to allow the user to download or print the file from the client or not.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue if the viewer was opened on the client; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.\n## Remarks\nThis method works only in Business Central on-premises environments. For online environments, use file-viewfromstream-method.\n## Example\nThis example shows how to use the File.View method to preview a file that resides on the Business Central server on the client computer.\n```al\nprocedure ViewServerFileOnClient()\nvar\n    ServerFileName: Text;\n    Success: Boolean;\nbegin\n    // Full path to a file that exists on the Business Central server computer\n    ServerFileName := 'C:\\Temp\\Top10Customers.pdf';\n\n    // Open the file on the client computer in preview mode,\n    // allowing the user to download and print it\n    Success := File.View(ServerFileName, true);\n\n    // Handle the case where the file could not be displayed\n    if not Success then\n        Error('Failed to display the file.');\nend;\n```\n> TIP\n> Use this method to provide the built-in file preview experience in Business Central for supported PDF and image files. Users can preview content directly in the client instead of downloading the file first.\n> Supported image formats include JPEG, JPG, PNG, BMP, SVG, WEBP, ICO, GIF, and AVIF. On Safari, TIFF and TIF images are also supported.\n> The base application uses this method to preview attachments on sales documents, item cards, and other records. Learn more in the Table \"Document Attachment\" reference.\n## Related information\nfile-data-type\nGetting started with AL<../../devenv-get-started>\nDeveloping extensions<../../devenv-dev-overview>"}