Write Hello World With iTextSharp

Like any new programming language or API, we all try to write a simple Hello World applicaion. Here is a simple console application that demonstrates how you can write a simple .Net application to write Hello World in a new PDF file.


static void Main(string[] args)
{
var doc = new iTextSharp.text.Document();
using (var fs = new FileStream("Hello.pdf", FileMode.OpenOrCreate))
{
PdfWriter writer = PdfWriter.GetInstance(doc, fs);
doc.Open();
doc.Add(new Paragraph("Hello ByteBlocks!"));
doc.AddAuthor("ByteBlocks.com");
doc.AddHeader("bbHeader", "iText For .Net");
doc.Close();
}
}

Very simple to use. Code opens a file stream for PDF where content is to be written. It then creates an instance of PdfWriter and opens it. Then it write a paragraph and sets author information... and DONE!

Views: 927

Related

Error upgrading ASP.Net4 from ASP.Net2Server error or Application when Upgrading Existing ASP.Net 2.0 site to ASP.Net 4.0Internet Explorer does not connect to internet after disabling Verizon wireless accessInternet explorer does not connect to internet after disabling broadband wireless cardiText For .NetPDF Library for .Net iTextSharp. It is a .Net port of java based iTextCustom ASP.Net Control To Help Add Links To Social Networking SitesCustom ASP.Net Control To Help Add Links To Social Networking Sites. ShareIt button for PHP,JSP,ASP,...Unable to change ASP.Net version in IISASP.Net version getting set to 4.0 in IIS when creating virtual directory using IIS manager

Powered by BlogEngine.NET 1.5.1.7
Theme by Naveen Kohli