Debenu PDF works on localhost fails on azure

こ雲淡風輕ζ 提交于 2019-12-25 18:25:33

问题


I'm using Debenu PDF Library to extract pages from a pdf file. Here is how I do it,

var pdflib = new PDFLibrary(LoadDll());
int result = pdflib.UnlockKey("UNLOCKKEYISHERE");

AzureStorageWrapper sasWrapper = new AzureStorageWrapper(ConfigurationManager.AppSettings["AzureStorageConnection"], "cont1");
byte[] blob = sasWrapper.GetBlob("file.pdf");

pdflib.LoadFromString(blob, "");
byte[] page = pdflib.RenderPageToString(50, 1, 1);

When I run this on my local machine it works perfectly (first page of the PDF file comes to the page byte array).

But after publishing this as an Azure Web App page gets a some useless string of bytes.

Can anyone explain to me why this is?


回答1:


You've hit an Azure App Service sandbox runtime exectution limitation.

From https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks:

Unsupported frameworks

Here is a list of frameworks and scenarios that have been found to be not be usable due to one or more of the restrictions above. It's conceivable that some will be supported in the future as the sandbox evolves.

PDF generators failing due to restriction mentioned above:

EVOPDF
Rotativa
wkhtmltopdf
Syncfusion
Siberix
NReco (uses wkhtmltopdf)
Spire.PDF

Other scenarios:
PhantomJS/Selenium: tries to connect to local address, and also uses GDI+.

It's probably safe to say you can add Debenu PDF to that list.

There is however a mention that some GDI calls may work on Basic/Standard pricing tiers in App Service. It's worth giving that a go if you're currently on Free/Shared.

Alternatives to App Service for running stuff that uses GDI/GDI+:

  • A Web/Worker Role (Cloud Services)
  • Service Fabric
  • IaaS Virtual Machine

Similar question here: What could cause EvoPDF "unable to render html" exception when deployed to Azure Website



来源:https://stackoverflow.com/questions/38563426/debenu-pdf-works-on-localhost-fails-on-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!