How to Merge PDF Files in Business Central Using a Python API
When working with documents in Microsoft Dynamics 365 Business Central, sometimes we need to combine multiple PDF files into a single document — for example, when generating a bundle of invoices or reports.
In this post, I’ll show you how to achieve that by integrating Business Central AL code with a Python-based API using FastAPI and PyPDF2.
🐍 The Python API (FastAPI + PyPDF2)
We’ll expose a /merge-pdf
endpoint using FastAPI that:
-
Accepts a list of PDFs encoded in Base64
-
Merges them using
PyPDF2.PdfMerger
-
Returns the combined PDF as a Base64 string
Here’s the Python code:
⚙️ The AL Code in Business Central
Here’s the AL codeunit that sends the list of PDF Base64 strings to the Python API:
✅ Benefits of This Integration
-
No need for third-party components inside Business Central
-
Flexible — works with any external Python service
-
Easy to deploy and extend
Comentarios
Publicar un comentario