Azure 应用服务(以前称为网站)有很多限制,所以我想知道 iText 的 PDF 创建工具是否仍然有效。具体来说,我会将 HTML 转换为 PDF,包括各种样式和图像。
由于其局限性,rotativa 和 Pechkin 均不适用于 Azure 应用服务。
最佳答案
There are many limitations with the Azure App Service (formerly websites), so I was wondering if iText's PDF creation tools still worked.
根据我对以下示例的测试,我可以使用 iText 7生成PDF文件,它在Azure App Service Web App上运行良好。
var path = Server.MapPath("test.pdf");
FileInfo dest = new FileInfo(path);
var writer = new PdfWriter(dest);
var pdf = new PdfDocument(writer);
var document = new Document(pdf);
document.Add(new Paragraph("hello world"));
document.Close();
生成的 PDF:
此外,我正在使用 iText 的基本功能,它在 Azure Web App sandbox 上运行良好.如果 iText 的任何高级功能无法在沙箱上运行,您可以尝试其他托管选项(例如云服务、虚拟机)。
关于itext - iText(任何版本)是否适用于 Windows Azure 网站?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45471073/