PDFLib x64バージョンをダウンロードして、WindowsAzureWebロールを簡単に試してみました。ライブラリには、PDFlib_dotnet.dllとして1つのDLLのみが含まれています。これを参照として追加し、そのプロパティを「ローカルをTrueとしてコピー」に設定できます。その後、コードでそれを参照し、ドキュメントに基づいて使用することができます。
私の簡単なテストに基づいて、Windows Azureローカルストレージを使用してPDFファイルを作成し、Windows Azure Blobストレージに同期して適切に永続化するように、コードを変更する必要があります。PDFをAzureBlobストレージに直接作成する方法があるかもしれませんが、私はそれ以上調べませんでした。
次のコードを使用してASP.NETベースのWebロールを作成しました。
PDFlib p;
int font;
p = new PDFlib();
try
{
// This means we must check return values of load_font() etc.
p.set_parameter("errorpolicy", "return");
// Added code to create PDF on Local Storage
LocalResource myStorage = RoleEnvironment.GetLocalResource("myLocalStorage");
string filePath = Path.Combine(myStorage.RootPath, "hello.pdf");
if (p.begin_document(filePath, "") == -1)
{
Console.WriteLine("Error: {0}\n", p.get_errmsg());
return;
}
p.set_info("Creator", "hello.cs");
p.set_info("Author", "Rainer Schaaf");
p.set_info("Title", "Hello, world (.NET/C#)!");
p.begin_page_ext(595, 842, "");
font = p.load_font("Helvetica-Bold", "unicode", "");
if (font == -1)
{
Console.WriteLine("Error: {0}\n", p.get_errmsg());
return;
}
p.setfont(font, 24);
p.set_text_pos(50, 700);
p.show("Hello, world!");
p.continue_text("(says .NET/C#)");
p.end_page_ext("");
p.end_document("");
}
catch (PDFlibException eX)
{
// caught exception thrown by PDFlib
Console.WriteLine("PDFlib exception occurred in hello sample:\n");
Console.WriteLine("[{0}] {1}: {2}\n", eX.get_errnum(),
eX.get_apiname(), eX.get_errmsg());
}
finally
{
if (p != null)
{
p.Dispose();
}
}
}