www.jlion.com

Thursday, January 24, 2008

Today I found a very cool open source project on SourceForge. iTextSharp is a DotNet 1.1 port of iText, which is a Java library for PDF creation. I found that it updates to VS2005 just fine and is very easy to use, at least for simple tasks (I'll let you know about more complex ones later on :)

Double kudos to those responsible for putting this great library together.

For example, creating a PDF document with iTextSharp is this easy:
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports System.IO

Partial Class docs_PrintSurvey
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oDocument As New Document

Dim sFileName As String = "c:\inetpub\myapp\temp\test.pdf"
PdfWriter.GetInstance(oDocument, New FileStream(sFileName, IO.FileMode.Create))

oDocument.Open()
oDocument.Add(New Paragraph("Hello World!"))
oDocument.Close()

Response.Redirect("http://mypc:1770/myapp/temp/test.pdf")
End Sub
End Class

0 Comments:

Post a Comment

<< Home