How to Merge PDF Files in Microsoft Dynamics 365 Business Central

How to Merge PDF Files in Microsoft Dynamics 365 Business Central

In today’s fast paced world of business, companies are always looking for ways to optimize processes as they interact with customers, supply chain, warehouse systems, and more. Recently, our team had a request to merge pdf files within Microsoft Dynamics 365 Business Central SaaS, but our customer couldn’t use external Dynamic Link Library (DLL) files or dotnet to merge PDF files, since those file formats are not supported in the SaaS environment.

This customer needed to send sales documents with Terms and Conditions as well as Warranty terms in one pdf document to their customers. The customer sends large volumes of sales orders and some invoices and were worried that if this information wasn’t sent together that customers would not view them.

Initially, we thought the perfect solution was already available in Business Central via the Document Sending Profiles and the “Combine” option. However, I evaluated this feature and attempted to write logic that would attach the Terms and Conditions pdf to the Sales Order report. 

Unfortunately, this didn’t work. The out-of-the-box Business Central PDF feature is simply setting a document number filter and running the sales report that creates one pdf with all orders via the filter. It doesn’t string PDFs of each document. 

A Logical Solution via the Control Add-in Library

From there, I moved on and did some research for a way to make this work and finally found the perfect solution via a post from Gonzales Rios Ley, which uses a control add-in from PDF-LIB JavaScript library to append documents to each other in Business Central. Don’t be scared, it is simpler than it sounds. This control add-in feature does not require any software to be installed or any external DLL files. The best news is that it works for Business Central SaaS and On-Premises servers. 

PDF merged files Business Central SaaS

The solution does include some basic functions to merge pdf documents in Business Central and this is completed by using the PDF-LIB JavaScript library on the user’s browser. The basic functions will include Report ID and a RecordRef variable or just a base64 string of the pdf — for more insights on this approach, visit Rios Ley’s Github

And there are a few “gotchas” that I just want to point out up front in case you try this on your own:

  1. The Print button does not display the report on the monitor as it is a PDF and is therefore downloaded to the download folder. I put a message in for the user, ‘Please refer to your download folder to get the document’
  2. Calling the download logic from a custom codeunit does not work. You must have the control add-in logic on the Page with the Print w/TnC action button as is supplied in the example from Gonzales Rios Ley.

Learn More About ArcherPoint’s Support Options

While Rios Ley offers basic logic for this particular challenge, ArcherPoint can deliver on-going support for more complicated requirements. We serve support clients 24 x 7 x 365 with highly responsive, experienced Tier 2 and Tier 3 team members who are ArcherPoint employees — not a distant outsourced entity. If you have any questions about customer support options, please contact us.

Trending Posts

Stay Informed

Choose Your Preferences
First Name
Last Name
Subscription Options
Your Privacy is Guaranteed