所以,我需要一个PDF生成器为我的ASP.NET应用程序。我下载了iTextSharp,因为它似乎是最流行的免费版本。但是在搜索互联网之后,我并没有真正找到我需要的信息来让我开始。到目前为止我发现的几个教程太混乱了。我知道那里有一本书,但我是一名学生,不想花这笔钱。我只需要真正基本的分步信息,最好是使用VB中的代码。目前为止我发现的最基本的教程是http://www.mikesdotnetting.com/Article/80/Create-PDFs-in-ASP.NET-getting-started-with-iTextSharp,但它不适合我。我试图按照它与这个代码想出了:如何使用iTextSharp?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var doc1 = new Document();
string path = Server.MapPath("PDFs");
PdfWriter.GetInstance(doc1, new FileStream(path + "/Doc1.pdf", FileMode.Create));
doc1.Open();
doc1.Add(new Paragraph("My first PDF"));
doc1.Close();
}
}
但它给我一个错误:“CS1502:为“iTextSharp.text.pdf.PdfWriter.GetInstance(iTextSharp.text最佳重载的方法匹配。 Document,System.IO.Stream)'有一些无效的参数“,并突出显示的行是PdfWriter.GetInstance ...
因此无论如何,我想知道是否有人知道我在本教程中做了什么错误,或者其他我可以使用的教程。或者,如果你想给我一个关于如何用你自己的话开始的基本解释,那会很好。请记住,不幸的是我对此一无所知。 :) 谢谢。
其他错误信息是什么? – SLaks 2011-05-22 02:35:24
CS1729:'System.IO.FileStream'不包含带1个参数的构造函数 – Sara 2011-05-22 02:43:48
这段代码使用iTextSharp v5.0.6.0 – 2011-05-22 02:45:10