0
votes

I've worked a lot with Azure websites but not cloud services. I need to spin up a cloud service that uses a third party dll to generate pdfs (http://wkhtmltopdf.org/). However, I would like to write this server in nodejs and almost all examples are in asp.net. I just need to know how to reference and execute this dll (or exe, if that's easier) from node js in an Azure Web Role when a request comes in. I'd greatly appreciate any pointers.

Thanks, Sam

EDIT: It's not necessarily a matter of referencing or using the dll from the code that I will have an issue with. It's how to INSTALL the dll on an Azure web role. All you can do in an Azure cloud service / web role is upload the project package but no explanation on how to add a dll or exe (except in asp.net, which I am not using. I'm using nodejs).

3

3 Answers

1
votes

You can put the installer in your web role package, and set up a startup task in the ServiceDefinition.csdef file for the roles. Here is the sample on official site Install .NET on a Cloud Service Role, which is guiding to install .NET in Cloud service, the steps and scenario should be the same.

0
votes

There are a lot of wrappers for wkhtmltopdf. This one is nice and pipable (you can stream the output directly to your client):

var wkhtmltopdf = require('wkhtmltopdf');

// URL 
wkhtmltopdf('http://google.com/', { pageSize: 'letter' })
  .pipe(fs.createWriteStream('out.pdf'));

// HTML 
wkhtmltopdf('<h1>Test</h1><p>Hello world</p>')
  .pipe(res);

You have to install wkhtmltopdf (the command line tool) first of course.

0
votes

Assuming that the dll is a managed assembly (i.e. an assembly compiled using .net), you can use edge.js to get NodeJS to interact with the dll.

If it is an exe, you can execute the process via NodeJS's asynchronous process creation API.