问题描述
我正在使用 WKHTMLTOPDF 库将html转换为pdf,以前我将应用托管在ubuntu服务器上,可以在其中通过命令行安装该库,
我想迁移到Azure应用程序服务,无论如何,我可以在Azure Windows平台中使用该库(wkhtmltopdf)
请帮助我.
我知道,对于Windows上的Azure WebApp,不支持任何使用GDI的应用程序,因为存在
但是,不使用GDI的 wkhtmltopdf
是一个特殊的框架,可以在Windows的Azure WebApp上使用,但是必须首先在没有GUI交互的情况下在Azure WebApp上安装它.
因此,唯一的方法是首先从
图2. GitHub发布页面
然后将其解压缩到本地并将其添加到您的PHP项目中,然后将 wkhtmltopdf
的 bin
路径附加到 PATH
的尾部通过PHP函数 getenv
和在PHP开头的 putenv
应用程序或尝试通过在 web.config
文件的 appSettings
中添加键 PATH
来设置 PATH
值.
最后,您可以使用第三方库 mikehaertl/phpwkhtmltopdf
在Windows版Azure WebApp上将HTML转换为PDF.
I'm using WKHTMLTOPDF library for converting html to pdf, previously I hosted my app on ubuntu server, where i can install the library via command line,
I want to migrate to Azure app services, Is there anyway I can use this library (wkhtmltopdf) in Azure windows platform
Please help me on this.
As I known, for Azure WebApp on Windows, any app using GDI is not supported, because there is a Win32k.sys (User32/GDI32) Restrictions introduced by the offical wiki pageAzure Web App sandbox, as the figure below.
However, wkhtmltopdf
without using GDI is a special framework which can be used on Azure WebApp for Windows, but you have to install it first on Azure WebApp without GUI interactive.
So the only way is first to download the MXE (MinGW-w64)
release files of 7z
archive format for Windows from the downloads page of offical site or GitHub releases page, as the figures below,
Fig 1. The offical downloads page
Fig 2. The GitHub releases page
And to unzip it on local and add it into your PHP project, then append the bin
path of wkhtmltopdf
to the tail of PATH
environment variable via PHP functions getenv
and putenv
at the start of your PHP app or try to set the PATH
value via add a key PATH
in appSettings
of web.config
file.
Finally, you can use the 3rd party library mikehaertl/phpwkhtmltopdf
to do the convert function from HTML to PDF on Azure WebApp for Windows.
这篇关于如何在Azure Windows App中启用wkhtmltopdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!