Integrating Software AG and Microsoft Azure function app to generate PDF output files

This tutorial describes how to generate PDF files in using Microsoft Azure Function and html-pdf Node JS library. The use-case is to showcase how we can integrate with Microsoft Azure function. Html-pdf node js is one example, there are multiple other libraries in different programming languages to generate PDF files. You can use the right one as per your requirement.

• Have access to cloud instance
• Access to Microsoft Azure with valid subscription –
• Knowledge on Html-PDF node js library -

Create Microsoft Azure Function App
• Azure function helps accelerate and simplify application development with serverless compute. Read more -
• Login to
• Search for Function App
• Click New to start creating a new Function App
• Select Appropriate Subscription, Resource Group, App name.

  • Select runtime stack as Node.js
  • Version 10 LTS
  • Region as per your choice


• Click Next to setup Hosting. It is important to note that, to execute html-pdf node.js library, you need to select minimum Basic B1 App service plan. Consumption plan will not work.


• Create the Azure Function App

Setup the created Microsoft Azure Function App
After successful deployment of the Azure function, you need to setup the node js code.
• Navigate to the newly created function App and create new function. Select HTTP trigger so that this function can be invoked from


• Open Console, navigate to the newly created function and install html-pdf library


• Open developer console and use the below node JS code


var pdf = require('html-pdf');

module.exports = async function (context, req) {
    const html=( || (req.body &&;
    var data = await returnHtmlAsPdf(html);
    var data2 = []
    context.res = {
        setEncoding: 'binary',
        // status: 200, /* Defaults to 200 */
        body: Buffer.concat(data2)

async function returnHtmlAsPdf(html) {
    return new Promise((resolve, reject) => {
        pdf.create(html).toBuffer(function(err, buffer){

• You will also need to include package.json file in root directory. Sample below

   "name": "PdfFunc",
   "version": "",
   "description": "",
   "scripts": {
     "test": "echo \"No tests yet...\""
   "author": "",
   "dependencies": {
     "html-pdf": "^2.2.0"

• This is how your final project structure looks like


• Copy the URL to invoke this function

image Workflow

In this example, I am considering a use case where we have JSON input.


• The first step is to convert JSON input to HTML
• Use HTTP Request Connector to invoke the Azure Function App by passing the HTML as input
• The response from the Azure function App will be PDF byte array
• Write the response to file and send the file in Email as attachment.

HTTP connector settings


Please note to set response encoding to binary


Also write the file with binary encoding