So, I need a PDF generator for my ASP.NET application. I downloaded iTextSharp because it seems the most popular free. But after searching the Internet I can’t find the information I need to get started. The few tutorials I've found so far are too confusing. I know a book there, but I am a student and do not want to spend money. I just need really basic step-by-step information, preferably with code in VB. The most basic tutorial I've found so far is http://www.mikesdotnetting.com/Article/80/Create-PDFs-in-ASP.NET-getting-started-with-iTextSharp , but it does not work for me. I tried to follow it and came up with this code:
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(); } }
But this gives me an error: "CS1502: best overloaded method matching for" iTextSharp.text.pdf.PdfWriter.GetInstance (iTextSharp.text.Document, System.IO.Stream) "contains some invalid arguments" and the highlighted line is PdfWriter.GetInstance ...
Somehow, I was wondering if anyone knows what I did wrong in this tutorial, or what other tutorials I can use. Or, if you want to give me a basic explanation of how to start my words, that would be great. Keep in mind, unfortunately, I don’t know anything about this. :) Thank you.
Sara
source share