我下载和PDFLib来的x64版本和给快速尝试使用Windows Azure Web角色的服务器。该库只包含一个作为PDFlib_dotnet.dll的DLL,您可以将其添加为参考,并将其属性设置为“Copy Local As True”。之后,您可以在代码中引用它并根据文档使用它。
根据我的快速测试,你确实需要修改使用Windows Azure的本地存储来创建PDF文件,并同步到Windows Azure Blob存储正确坚持它的代码。可能有办法直接创建PDF到Azure Blob存储,但我只是没有看得更远。
我创建了一个ASP。NET基于webrole用下面的代码:
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();
}
}
}
接受我自己的答案,因为它来自PDF lib支持并涵盖所有要点。感谢Steve,Mike,Avkash提供有用的信息。 – JcFx 2012-08-20 08:19:21