Change document Font Size in ITextSharp

I have this little script that generate a table in a .pdf file, but the text is too big. How do I add another font size/type for it?

Dim form As New HtmlForm

form.Controls.Add(gvEvents)
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter(sw)
Dim htmlContent As String = sw.ToString()

Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=Holdkalender.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)

form.Controls(0).RenderControl(htmlWriter)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 50, 50, 50, 50)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.End()

EDIT:

I have tried this, but it gives me an Ielement Error:

Protected Sub btnGeneratePDF_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGeneratePDF.Click
BindEvents(Convert.ToInt32(ddlEventSize.SelectedValue))
Dim form As New HtmlForm

form.Controls.Add(gvEvents)
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter(sw)
Dim htmlContent As String = sw.ToString()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=Holdkalender.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)

form.Controls(0).RenderControl(htmlWriter)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 50, 50, 50, 50) 'Paper Size and margin
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
Dim ftlbl As Font = Nothing
ftlbl = FontFactory.GetFont(FontFactory.HELVETICA, 5)
pdfDoc.Add(ftlbl)
Try
    htmlparser.Parse(sr)
Catch ex As Exception
    'Display parser errors in PDF.
    Dim paragraph As New Paragraph("FEJL!" + ex.Message)
    Dim text As Chunk = TryCast(paragraph.Chunks(0), Chunk)
    If text IsNot Nothing Then
        text.Font.Color = BaseColor.RED
    End If
    pdfDoc.Add(paragraph)
Finally
    pdfDoc.Close()
    Response.Write(pdfDoc)
    Response.End()
End Try

End Sub

EDIT 2:

Answers


You can use something like this to give format to your table titles

EDIT

//add a Paragraph to the document with an specify format
 Dim TableFont   = FontFactory.GetFont("Arial", 12, Font.BOLD)

 pdfDoc.Open()  
 pdfDoc.Add(New Paragraph(sr.ReadToEnd(),TableFont)

Need Your Help

Redeclaration of a variable in a for-loop in C++

c++ for-loop declaration

When trying to compile the following (simplified) code for multiple platforms, I found that it was failing on some, namely IBM's xlC_r. Further investigation has found that it also fails on comeau...

Getting only certain values from an array

php arrays

I have an array with the following values