【问题标题】:Azure App Service: Converting docx to pdfAzure 应用服务:将 docx 转换为 pdf
【发布时间】:2017-05-30 14:14:37
【问题描述】:

有人知道 Azure 应用服务(标准层)是否支持将 docx 转换为 pdf。

我知道 GDI+ 问题,但我没有找到任何信息,哪些部分不受支持,或者自从记录了这些限制后它是否已更改。

我问的原因是我已经测试了第三方组件(Aspose.Words for .NET),它可以成功地将测试 docx 文件转换为 pdf。

因此我想知道是否支持有限的一组功能(因为 docx 文件仅包含徽标、文本和表格),或者我是否在不受支持的灰色区域中运行。

谢谢!

最好的问候, 约翰

【问题讨论】:

    标签: pdf azure-web-app-service


    【解决方案1】:

    我安装Aspose.Words for .NET 并在我这边进行测试以将 docx 转换为 pdf,并在我的 Azure 应用服务(标准应用服务计划/定价层)上托管 Web 应用,效果很好。

    代码 sn-p:

    HttpPostedFile postedFile = SrcFileUpload.PostedFile;
    string dstExtension = "pdf";
    string dstFileName = Path.GetFileName(postedFile.FileName) + "_Converted." + dstExtension;
    SaveFormat dstFormat = FileFormatUtil.ExtensionToSaveFormat(dstExtension);
    
    
    Document doc = new Document(postedFile.InputStream);
    doc.Save(Response, dstFileName, ContentDisposition.Inline, SaveOptions.CreateSaveOptions(dstFormat));
    Response.End();
    

    结果:

    您也可以参考“How to Convert Documents in Windows Azure”,它显示了转换文档的完整代码。

    【讨论】:

    • 也感谢您自己的测试。我也测试过它并得到相同的结果。但是网上有很多消息说它不起作用,应该改用云服务。所以,我只是想知道是否发生了一些变化,现在支持它,或者我们在测试中只使用了有限的一组功能,这些功能在转换文档时受支持,但是在使用“高级”功能时,我们会遇到麻烦,因为GDI+ 限制。但到目前为止我找不到任何官方文档。
    • we only use a limited set of features in our tests that are supported when converting documenents but when using "advanced" features we would get into trouble 我同意你的观点,也许我们只是在测试示例中使用了基本功能,所以它可以很好地与 Azure 应用服务一起使用。在许多官方示例中,我们可以发现应用程序是作为云服务 WebRole 实现的,如果可能的话,我建议您可以选择云服务。
    猜你喜欢
    • 2011-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-14
    • 2017-08-17
    • 2018-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多