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。 –