Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Make a PDF file from

Posted by Viral Sarvaiya on July 8, 2009

to make a pdf file hear I demonstrate as below,

you have to take a itextsharp.dll file from the following link

now the code is as follows,

Imports iTextSharp.text
Imports iTextSharp.text.pdf

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack = False Then
End If
End Sub

Sub makepdf()

Dim labelFont14 As Font = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 14, Font.NORMAL)
labelFont14.Color = New iTextSharp.text.Color(0, 25, 25)

Dim labelFont12 As Font = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL)
labelFont12.Color = New iTextSharp.text.Color(0, 25, 25)

'as like that you can define the font.

PageSize.A4.BackgroundColor = New iTextSharp.text.Color(255, 255, 255)
Dim doc As Document = New Document(PageSize.A4, 1, 0, 0, 30)
PdfWriter.GetInstance(doc, New FileStream(Server.MapPath("path/filename.pdf"),FileMode.Create))
doc.AddAuthor("Author name")


Dim tablemain As Table = New Table(1)

'here table(1) denotes the 1 collumns, when u add the cell then it creates the one column and then 2nd cell is make the 2nd row for that column

tablemain.BorderWidth = 0
tablemain.Width = 100.0F
tablemain.Padding = 0
tablemain.Spacing = 0

Dim celln As New Cell(New Chunk(“string” & vbCrLf, labelFont14))
celln.Width = 90.0F
celln.HorizontalAlignment = Element.ALIGN_CENTER



as per your requirements you can set the collumns and rows


One Response to “Make a PDF file from”

  1. […] my past post is demonstrate how to develop the pdf file, but when i search in web that have less example for the […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: