Skip to content

This node.js Azure function converts Pdfs in blob storage to image files, also stored in blob storage. This can be useful for Microsoft Cognitive Services like OCR that need documents in PNG format.

License

Notifications You must be signed in to change notification settings

tyayers/Azure-Pdf-Imager-Function

Repository files navigation

Azure-Pdf-Imager-Function

This node.js Azure function converts Pdfs in blob storage to image files, which are then also saved to blob storage. This can be useful for Microsoft Cognitive Services like OCR that need documents in PNG format.

Flow Diagram

Here is the typical user flow for this function. PDF conversion flow

Usage

Deploy this function in Azure using the Continuous Deployment functionality as documented here: Continuous deployment for Azure Functions

Configuration

You can configure these environment variables in the Function App (see How to manage a function app in the Azure portal > App settings for more details).

  • StorageConnectionString: Storager account connection string where the files are stored / uploaded.

The file function.json in the PdfImageConverter contains the exact configuration in which blob directories the function reacts to when PDFs are uploaded (blobTrigger > Path) and where the PNG files are stored after conversion (myOutputBlob > Path).

PdfImageConverter/function.json

{
  "disabled": false,
  "bindings": [
    {
      "name": "myBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "docs/{name}", // Source blob PDF directory
      "connection": "StorageConnectionString"
    },
    {
      "name": "myOutputBlob",
      "type": "blob",
      "path": "images/{name}.png",  // Destination blob PNG directory
      "connection": "StorageConnectionString",
      "direction": "out"
    }
  ]
}

About

This node.js Azure function converts Pdfs in blob storage to image files, also stored in blob storage. This can be useful for Microsoft Cognitive Services like OCR that need documents in PNG format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published