Hi Amit Developer- Atlantic,
Option1:Install Dependencies via Startup Script (Best for Azure App Service Linux)
Modify your startup.sh
to install the missing dependencies before starting your app:
#!/bin/bash
apt-get update && apt-get install -y \
libjpeg62-turbo \
libxrender1 \
libxext6 \
xfonts-base \
xfonts-75dpi \
wkhtmltopdf
gunicorn --bind=0.0.0.0 --timeout 600 app:app
It installs Libjpeg62-Turbo, which provides Libjpeg.so.62. Also ensure that this is the script: Saved in his project directory, marked as executable, and Configured as a startup command in Azure.
https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux&tabs=debian
https://learn.microsoft.com/en-us/azure/app-service/overview#supported-linux-distributions
Option2:Use the fully bundled Wkhtmltopdf
build (portable static version)
Download the static (self-contained) Linux Build of Wkhtmltopdf
from his official site:
https://wkhtmltopdf.org/downloads.html
Use a version like wkhtmltox-0.12.6-1.alpine3.17_x86_64.apk.tar.gz
or wkhtmltox-0.12.6-1-centos7-amd64.tar.xz
Remove it in your project (/bin) folder.
Update your Python code to use the bundled path:
import pdfkit
config = pdfkit.configuration(wkhtmltopdf='/home/site/wwwroot/bin/wkhtmltopdf')