0
我想使用.NET生成动态PDF。我找到的库是QuickPDFLibrary。我知道还有其他几个库可以做到这一点,比如iTextSharp;但是,他们需要商业应用许可证。 QuickPDFLibrary指出他们支持ASP.NET;然而,我似乎无法让它工作,并且无法在他们的网站上找到与ASP.NET一起使用它的文档。我按照程序设置了DLL和ActiveX,但无法让它们中的任何一个在aspx页面的上下文中工作。我的代码如下。使用QuickPDFLibrary动态PDF生成
public partial class _Default : System.Web.UI.Page
{
public QuickPDFAX0816.PDFLibrary qp;
protected void Page_Load(object sender, EventArgs e)
{
qp = new QuickPDFAX0816.PDFLibrary();
}
protected void Button1_Click(object sender, EventArgs e)
{
qp.UnlockKey("UNLOCK KEY HERE");
// This function draws text onto a document
// Setup the parameters
string fileName = "drawText.pdf";
// Check to see if the library has been successfully unlocked
if (qp.Unlocked() == 1)
{
// Set origin co-ordinates to top left of page
qp.SetOrigin(1);
// Call the DrawText function
qp.DrawText(100, 100, "Hello world from C# and the ActiveX edition of Quick PDF Library");
// Save the changes to the document on the local disk (in the debug folder)
int result = qp.SaveToFile(fileName);
if (result == 1)
{
Console.WriteLine("IT worked!");
}
else
{
Console.WriteLine("IT failed!");
}
// Open PDF automatically
//System.Diagnostics.Process.Start(fileName);
}
else
{
// If library could not be unlocked warn the user
Console.WriteLine("License key could not be validated. The library was not unlocked.");
}
}
}
大家好,谢谢你的建议。我决定去ABCpdf.NET。 –