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...
Suggested answer

Merging the pdf attachments and download in Business central

(0) ShareShare
ReportReport
Posted on by 15

Dear members,

I would like to know how to download two merge and download it as a single pdf. Consider a scenario, where I have two attachment in a sales order. I would like to get the two documents(PDF Format ) attached in a single document(PDF). 

Please suggest me an appropriate way to merge both the attachments and download it as a single file.

Thanks and Regards,

Vishal S

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    92,819 Super User 2025 Season 2 on at
    RE: Merging the pdf attachments and download in Business central

    Hi, you can try the solution below, I tested it in SaaS and it works.

    Merge PDF in Business Central (linkedin.com)

    GitHub - gonzaloriosley/Merge-PDF-Business-Central

    Hope this helps.

    Thanks

    ZHU

  • Suggested answer
    Nitin Verma Profile Picture
    21,684 Moderator on at
    RE: Merging the pdf attachments and download in Business central

    Hi,

    You can also use the function to zip of all the documents and download them.

    procedure ZipAllLabels(No: code[20])
        var
            datacompresion: Codeunit "Data Compression";
            ZipFileName: text;
            ItemCnt: Integer;
            FileName: text;
            TenantMedia: Record "Tenant Media";
            instrm: InStream;
            blobStorage: Codeunit "Temp Blob";
            ZipOutStream: OutStream;
            ZipInStream: InStream;
        begin
            ZipFileName := FileNo   '_'   Format(CurrentDateTime, 0, ':')   '.zip';
            datacompresion.CreateZipArchive();
            yourrecord.Reset();
            if yourrecord.findset then
                repeat
                    if TenantMedia.get(yourrecord."Label URL File".MediaId) then BEGIN
                        TenantMedia.CalcFields(Content);
                        if TenantMedia.Content.HasValue then begin
                            FileName := "No."   '_'   format("Sequence No.")   '.pdf';
                            TenantMedia.Content.CreateInStream(instrm);
                            datacompresion.AddEntry(instrm, FileName);
                            ItemCnt  = 1;
                        end;
                    end;
                until yourrecord.Next() = 0;
            blobStorage.CreateOutStream(ZipOutStream);
            datacompresion.SaveZipArchive(ZipOutStream);
            datacompresion.CloseZipArchive();
            blobStorage.CreateInStream(ZipInStream);
            DownloadFromStream(ZipInStream, 'Download zip file', '', '', ZipFileName);
        end;
    

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,285

#2
Sumit Singh Profile Picture

Sumit Singh 2,725

#3
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,526

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans