'''
''' create a pdf document using ItextSharp library
'''
''' path to the location of new file, include file name
''' download itextSharp.dll at http://sourceforge.net/projects/itextsharp/
Public Shared Sub makePDFDocument(ByVal strFilePath As String)
'if there are more than 9 columns for displaying result, we should use A4 landscape size to present
Dim document As Document = New Document
'or for LandScape size: New Document(PageSize.A4.Rotate())
Try
'create a pdf file
PdfWriter.GetInstance(document, New FileStream(strFilePath, FileMode.Create))
document.Open()
'add a paragraph
Dim pr As New Paragraph("Sample paragraph: To make a graph, you first create a graph with text, font, fontsize,FontStype, FontForeColor", New Font(text.Font.TIMES_ROMAN, 13, text.Font.BOLD, text.Color.DARK_GRAY))
pr.Alignment = Element.ALIGN_CENTER
document.Add(pr)
'add an image
Dim imgUrl As String = "http://www.google.com.sg/images/nav_logo3.png"
Dim img As New iTextSharp.text.Jpeg(imgUrl)
img.Alignment = Element.ALIGN_CENTER
document.Add(img)
'you can also add table to the page, see ItextSharp library,..
Catch ex As Exception
Finally
document.Close()
End Try
End Sub
|