Announcements
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
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;
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
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator