The Public Preview of Microsoft Business Central Release 2025 Wave 1 is now available, and it is time to test out the available new features. One of the new features that excites me the most is the “Preview PDF attachments directly in web client” user experience feature. Previously, when needing to view a PDF attachment that is stored in Business Central, the user would need to download and open the attachment. With this new feature, users have a smooth and easy way to work with attachments, report outputs, or incoming documents while remaining productive in the work context, saving time and effort.
The best part of this feature is that it is accomplished with one line of code from an AL development perspective. AL developers can easily add this feature to their extensions without a lot of additional coding. Viewing a PDF in the browser is done with the ViewFromStream of the File data type.
Note: File.ViewFromStream is for use with Business Central online and File.View is for use withBusiness Central on-premises
procedure Preview(InStr: InStream; FileName: Text)
begin
File.ViewFromStream(InStr, FileName);
end;
procedure Upload(InStr: InStream; var FileName: Text): Boolean
begin
exit(File.UploadIntoStream('Select a file to upload', '', 'PDF files (*.pdf)|*.pdf|All files (*.*)|*.*"', FileName, InStr));
end;
procedure UploadPreview()
var
InStr: InStream;
FileName: Text;
begin
if (File.UploadIntoStream('Select a file to upload', '', 'PDF files (*.pdf)|*.pdf|All files (*.*)|*.*"', FileName, InStr)) then
File.ViewFromStream(InStr, FileName);
end;
When viewing a PDF in the browser the rendering provides for a nice user experience.
Note: The code and information discussed in this article are for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2025 Wave 1 online.