Azure 函数中的 Html 到 Pdf 库 [英] Html to Pdf library in Azure Function

查看:13
本文介绍了Azure 函数中的 Html 到 Pdf 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure 函数显然还不支持 System.Drawing (sanbox 信息).运行依赖于它的函数会抛出以下消息:

Azure functions apparently doesn't yet support System.Drawing (sanbox info). Running a function with a dependency on it throws the following message:

System.Drawing is not supported on this platform.

我最初在 WebApp 中使用 Select.HtmlToPdf 来创建 PDF 文档来自 HTML.但是,由于将 PDF 生成移动到 Azure 函数,这不再是一种选择.

I was originally using Select.HtmlToPdf in a WebApp to create PDF documents from HTML. But, since moving the PDF generation to an Azure function, that is no longer an option.

另外,推荐的库是 wkhtmltopdf,但它似乎没有 .netstandard2.0 版本.

Also, the reccomended library is wkhtmltopdf, but that doesn't seem to have a .netstandard2.0 version.

您将如何使用 Azure Functions (C#) 完成 PDF 生成?

How would you accomplish PDF generation using Azure Functions (C#)?

更新:该函数正在 S1 - 应用服务计划上运行.

Update: the function is running on an S1 - App Service Plan.

Update2:使用 OdeToCode 给出错误 Qt:无法初始化 OLE(错误 80010106)

Update2: using the method shown on OdeToCode gives the error Qt: Could not initialize OLE (error 80010106)

推荐答案

此时我创建了一个新的 netcore2.0 Azure AppService API,它支持 Select.HtmlToPdf 和如果它在一段时间内仍然无法与 netcore3.0 一起使用,则可能会将其移动到容器中.该函数只是调用带有一些参数的API,可以等待PDF生成异步.

At this point I created a new netcore2.0 Azure AppService API that supports Select.HtmlToPdf and will probably move this functionality to a container if it still doesn't work with netcore3.0 in a little while. The function just calls the API with some parameters and can wait for the PDF generation async.

正如 Jerry 所提到的,它可能适用于 DinkToPdf.但是,模板 html 文档不得包含 JavaScript,因此此解决方案对我的用例无效.

As Jerry has mentioned, it might work with DinkToPdf. However, the template html docs must not contain JavaScript, so this solution is not valid for my use-case.

这篇关于Azure 函数中的 Html 到 Pdf 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆