web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Display PDFs from shared folder in BC On-Prem without saving them to the database

(4) ShareShare
ReportReport
Posted on by 9

Hi community,

I'm working with Business Central On-Premise version 25.1 (Platform 25.0.25866.0 + Application 25.1.25873.25900), in a hybrid code environment.

I already have a fully developed embedded PDF viewer (not the lite version), and until now I’ve been loading documents from the database using Document Attachment.

Now I want to change the approach and read PDF files directly from a local shared folder, for example: \\SRV_NAME\FOLDER_NAME , without storing them in the database.

My goal is to:

  1. Read the PDF file from the UNC path.
  2. Load it into a TempBlob.
  3. Display it embedded in Business Central using the viewer I already have.
  4. Delete the TempBlob after viewing.

The Business Central server has access to the shared folder, and the service runs under a user with the necessary permissions.

I don’t yet have the code to read from disk, and I’m not sure how to do it properly in AL (especially in OnPrem extensions). Could someone help me implement this flow step-by-step, with working AL code compatible with OnPrem?

Thanks in advance!

I have the same question (0)
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,436 Super User 2025 Season 2 on at
     
    try this procedure :
    procedure LoadPDFIntoTempBlob(UNCPath: Text; var TempBlob: Record TempBlob): Boolean
        var
            InStream: InStream;
            FileManagement: Codeunit "File Management";
            TempFile: Text;
        begin
            // Confirm path exists and ends with ".pdf"
            if not FileManagement.ServerFileExists(UNCPath) then begin
                Error('File not found: %1', UNCPath);
            end;
    
            if not StrEndsWith(LowerCase(UNCPath), '.pdf') then
                Error('File must be a PDF: %1', UNCPath);
    
            // Open the file as InStream
            FileManagement.ServerFileToInStream(UNCPath, InStream);
    
            // Prepare TempBlob
            TempBlob.Init();
            TempBlob.Blob.CreateInStream(InStream);
            TempBlob.Insert();
    
            exit(true);
        end;
    Best regards,
    Mohamed Amine MAHMOUDI
  • Gerardo Rentería García Profile Picture
    25,236 Most Valuable Professional on at
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
    You can search for previous NAV solutions, which are still available in BC On-Pre version.
    For example,
     
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans