所以,我需要一個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