Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports SelectPdf
Namespace SelectPdf.Samples
Partial Public Class pdf_text_element
Inherits System.Web.UI.Page
Protected Sub BtnCreatePdf_Click(sender As Object, e As EventArgs)
' create a new pdf document
Dim doc As New PdfDocument()
' create a new pdf font (component standard font)
Dim font1 As PdfFont = doc.AddFont(PdfStandardFont.Helvetica)
font1.Size = 20
' create a new pdf font (system font)
Dim font2 As PdfFont = doc.AddFont(New System.Drawing.Font("Verdana", 15))
' add a new page to the document
Dim page As PdfPage = doc.AddPage()
' define a rendering result object
Dim result As PdfRenderingResult
' create text element
Dim text1 As New PdfTextElement(0, 0, _
"Regular text using standard font Helvetica, size 20.", font1)
result = page.Add(text1)
' create text element
Dim text2 As New PdfTextElement(0, _
result.PdfPageLastRectangle.Bottom + 20, _
"Regular text using system font Verdana, size 15.", font2)
result = page.Add(text2)
' create colored text element
Dim text3 As New PdfTextElement(0, result.PdfPageLastRectangle.Bottom + 20, 200, _
"Red text over light blue background, using system font Verdana, size 15, limited at a width of 200 points.", font2)
text3.ForeColor = System.Drawing.Color.Red
text3.BackColor = System.Drawing.Color.LightBlue
result = page.Add(text3)
' create colored text element, right aligned
Dim text4 As New PdfTextElement(0, result.PdfPageLastRectangle.Bottom + 20, 300, _
"Red text over light green background, right aligned, using system font Verdana, size 15, limited at a width of 300 points.", font2)
text4.ForeColor = System.Drawing.Color.Red
text4.BackColor = System.Drawing.Color.LightGreen
text4.HorizontalAlign = PdfTextHorizontalAlign.Right
result = page.Add(text4)
' create text element
Dim text5 As New PdfTextElement(0, result.PdfPageLastRectangle.Bottom + 200, 300, _
"Regular text using system font Verdana, size 15, rotated 45 degrees.", font2)
text5.Direction = 45
' rotate 45 degrees counter-clockwise
result = page.Add(text5)
' save pdf document
doc.Save(Response, False, "Sample.pdf")
' close pdf document
doc.Close()
End Sub
End Class
End Namespace