A C# library for communicating with the PrintNode API
Let's set up your account first.
Create an API key at printnode.com.
Install your PrintNode client to the computer of your choice.
Open the PrintNode client and get the printer ID. Now let's "Hello, world!":
// Your PrintNode API key is stored in apiKey
// Your PrintNode printer id is stored in printerId
// Your awesome test PDF is stored as a byte[] in pdfDocumentBytes
PrintNodeConfiguration.ApiKey = apiKey;
var printer = await PrintNodePrinter.GetAsync(printerId);
var printJob = new PrintNodePrintJob
{
Title = "Hello, world!",
Content = Convert.ToBase64String(pdfDocumentBytes),
ContentType = "pdf_base64"
};
await printer.AddPrintJob(printJob);
You can set up several computers each with their own PrintNode client, and register them to the same PrintNode account.
var computers = await PrintNodeComputer.ListAsync();
[
{
"id": 11,
"name": "AnalyticalEngine",
"inet": null,
"inet6": null,
"hostname": null,
"version": null,
"jre": null,
"createTimestamp": "2015-06-28T18:29:19.871Z",
"state": "disconnected"
}
]
var computerId = 12777;
var computer = await PrintNodeComputer.GetAsync(computerId);
var printers = await PrintNodePrinter.ListAsync();
var printerId = 38409;
var printer = await PrintNodePrinter.GetAsync(printerId);
byte[] pdfDocument = await DownloadPdf("http://test.com/test.pdf");
var printJob = new PrintNodePrintJob
{
Title = "My cool test print",
Content = Convert.ToBase64String(pdfDocument),
ContentType = "pdf_base64"
};
var response = await printer.AddPrintJob(printJob);
var printerId = 38409;
var printJobs = await PrintNodePrintJob.ListForPrinterAsync(printerId);
var childAccount = new PrintNodeChildAccount
{
FirstName = "First name",
LastName = "Last name",
Email = "email@test.com",
Password = "password",
CreatorRef = "a cool ref"
};
var response = await childAccount.CreateAsync();
var accountId = response.Id.Value;
using (new PrintNodeDelegatedClientContext(accountId))
{
var printers = PrintNodePrinter.ListAsync();
}