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

Community site session details

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

Print Preview to Download PDF with Document Number as file name

(3) ShareShare
ReportReport
Posted on by 3,089
Hi All
When printing documents without print preview , document created with the number as file name. However when print preview and then download you only get document as field name as below. is there a way  to automatically create meaningful file name when downloading PDF?
I have the same question (0)
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    18,966 Super User 2025 Season 2 on at
    Print Preview to Download PDF with Document Number as file name
  • Suggested answer
    YUN ZHU Profile Picture
    90,019 Super User 2025 Season 2 on at
    Print Preview to Download PDF with Document Number as file name
    Hi, hope the following helps.
    Business Central 2024 wave 2 (BC25): Set the default filename for the downloaded reports (Custom Filename For Report Export) – OnGetFilename event
    Dynamics 365 Business Central: How to directly export Report from page (Custom Filename For Report Export)
     
    Thanks.
    ZHU
  • Verified answer
    Jeffrey Bulanadi Profile Picture
    6,939 on at
    Print Preview to Download PDF with Document Number as file name

    Hi Samantha73,

    You can address this using an event subscriber to overwrite the custom name.

    Subscribing to the following objects will give you the result you need:

     
    • Codeunit → Document-Mailing → OnBeforeGetAttachmentFileName
    • Table → Document Attachment → OnBeforeSaveAttachment
     

    If you find this useful, feel free to mark this answer as suggested!

    I've also created a GitHub repo with the code for you to check out.

    https://github.com/jeffreybulanadi/D365-BusinessCentral-Community-Solutions/tree/c5f60ba2eac022fe4d0a8ae2eaea705df342a635/AL-Extensions/PrintPreviewCustomFileName

    Cheers
    Jeffrey Bulanadi

  • Gerardo Rentería García Profile Picture
    22,524 Most Valuable Professional on at
    Print Preview to Download PDF with Document Number as file name

    Hi, good day
    I hope this can help you, and give you some hints.

    How to change the name of downloaded PDF?

    How to translate attachment names - FORNAV

    Microsoft Idea

    Best Regards
    Gerardo

  • Suggested answer
    RockwithNav Profile Picture
    7,972 Super User 2025 Season 2 on at
    Print Preview to Download PDF with Document Number as file name
    With some tweak you can but the major question lies, how many downloads you are doing a day. If it's handful then why not to download and then rename. I had a similar question from one of our client and then the same approach we took, if the volume is higher then we have to get into the processing logic of the base.
     
  • Suggested answer
    Sohail Ahmed Profile Picture
    10,977 Super User 2025 Season 2 on at
    Print Preview to Download PDF with Document Number as file name

    In Business Central, when using Print Preview, the default PDF file name may not include the document number. To ensure meaningful filenames during PDF downloads, here are a few approaches you can consider:

     

    1. Modify the Report Code to Include the Document Number

    • In AL, use the Report.SaveAs method.

    • Dynamically pass the document number as part of the file name when saving the report.

    2. Use the File.View Method

    • Allows previewing a file before download.

    • You can adjust the logic so the downloaded file includes the document number in the name.

    3. Customize the Report Layout

    • In Word or RDLC layouts, make sure the document number is visible in the header or footer.

    • This helps users identify and rename files more easily after download.

    4. Use the OnCustomDocumentMergerEx Event (v21+)

    • Available in Business Central v21 or later.

    • Allows customization of the document merge and file naming before generation.

     

    Mark below checkbox to make this answer Verified if it helps you.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,725 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,610

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,221

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans