11

Webforms Page Code behind

        XSettings.InstallRedistributionLicense("REDACTED");
        var theDoc = new Doc();
        theDoc.HtmlOptions.Engine = EngineType.Gecko;
        theDoc.Rect.Inset(72, 144);
        theDoc.Page = theDoc.AddPage();
        int theID = theDoc.AddImageUrl("http://www.woot.com/");
        while (true)
        {
            theDoc.FrameRect(); // add a black border
            if (!theDoc.Chainable(theID))
                break;
            theDoc.Page = theDoc.AddPage();
            theID = theDoc.AddImageToChain(theID);
        }
        for (int i = 1; i <= theDoc.PageCount; i++)
        {
            theDoc.PageNumber = i;
            theDoc.Flatten();
        }
        Response.Buffer = false;
        Response.AddHeader("Content-Disposition", "inline; filename=\"rept.pdf\"");
        Response.ContentType = "application/pdf";
        theDoc.Save(Response.OutputStream);
        Response.Flush();

should work pretty well.. but get

      Failed to add HTML: RPC to Gecko engine process failed.Remote process terminated unexpectedly.

Running Full trust have in bin folder

  • XULRunner Folder and everything from C:\Program Files (x86)\WebSupergoo\ABCpdf .NET 9.0\ABCGecko
  • ABCGecko.dll
  • ABCpdf.dll
  • ABCpdf9-32.dll

Package / Publish Web All files in this project folder

MarkKGreenway
  • 8,494
  • 5
  • 34
  • 53
  • removed all references and files... added nuget package http://nuget.org/packages/ABCpdf.ABCGecko still no luck – MarkKGreenway Nov 29 '12 at 19:49
  • there is a case study on the abcpdf site using worker roles not sure if you could utilise that perhaps http://www.websupergoo.com/abcpdf-windows-azure-altaine.htm – Daniel Powell Jul 16 '13 at 22:53
  • not really . worker roles have worked the whole time...still get errors https://gist.github.com/hurricanepkt/6021781 source demo http://abcpdf.azurewebsites.net/ (right side is the source). Microsoft has acknowledged this as a bug and were fixing it. – MarkKGreenway Jul 17 '13 at 15:46
  • did they say this somewhere? – Daniel Powell Jul 17 '13 at 22:52
  • In a private email to me from the dev team – MarkKGreenway Jul 18 '13 at 00:00
  • I have used DocRaptor for my HTML to PDF conversions for Azure websites. Their model is not optimal but it works on Azure. You POST your HTML to their site and they respond with the PDF. It is great if you need to do a few PDFs, but if you have high volume the pricing model falls over in favor of other methods. – stamm528 Oct 22 '13 at 16:50

2 Answers2

7

You are not allowed to run external processes from within your Windows Azure Website as this would pose a risk in the shared infrastructure.

See this post by a MSFT employee or that post where the same employee talks about other restrictions concerned with native APIs.

You can verify that the problem is related to the externally launched Gecko by not adding the HTML image to the document. For me the creation of the PDF progressed further but failed because of the missing license.

It looks like you would have to find a fully managed/.NET HTML rendering engine (if converting a website to PDF is your use-case) or hope that reserved-mode web sites gain the right to execute native/external processes.

Simon Opelt
  • 6,136
  • 2
  • 35
  • 66
  • 2
    This is out of date. Azure in 2012 is completely different from Azure now. Indeed the Windows Azure Website product doesn't exist any more. What exists now in 2017 is called an App Service and there are a variety of different flavors including a Web App one. Web Apps are cut down VMs, simple to use but restricted in control and funtionality. There are also Cloud Services which are a whole lot more powerful and also offer web services. Finally there are full featured Virtual Machines. See: https://cloudacademy.com/blog/microsoft-azure-app-service-virtual-machines/ – OnceUponATimeInTheWest Sep 02 '17 at 13:15
2

There are full ABCpdf Azure deployment guides here:

http://www.websupergoo.com/support-azure-abcpdf.htm