-1

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?

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
Kamal Rathnayake
  • 514
  • 3
  • 29

1 Answers1

2

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

Community
  • 1
  • 1
evilSnobu
  • 24,582
  • 8
  • 41
  • 71
  • 1
    EvoPdf has a solution for Azure Websites. Check the http://www.evopdf.com/azure-html-to-pdf-converter.aspx page for more details. – EvoPdf Jul 27 '16 at 18:44
  • The Wiki is now updated to reflect that -- https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks – evilSnobu Jul 27 '16 at 19:18
  • Thanks for updating that wiki page. May I suggest you to remove EvoPdf from that list of Azure incompatible frameworks and add it to a section containg the solutions addressing the Azure sandbox limitations? Currently there is a little bit of contradictory info our there. Is it possible for me to get edit permissions on that wiki page somehow? Thanks. – EvoPdf Jul 29 '16 at 13:40
  • I think it's best you open an Issue here https://github.com/projectkudu/kudu/issues - easier to track. Thanks! – evilSnobu Jul 29 '16 at 14:39