Public Class pdf_compression
    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()
        doc.Margins = New PdfMargins(20, 20, 20, 20)

        ' set compression level
        doc.CompressionLevel = DirectCast([Enum].Parse(GetType(PdfCompressionLevel), _
            DdlPdfCompressionLevel.SelectedValue, True), PdfCompressionLevel)

        ' create a new pdf font
        Dim font As PdfFont = doc.AddFont(PdfStandardFont.Helvetica)
        font.Size = 16

        ' add a new page to the document
        Dim page As PdfPage = doc.AddPage()

        ' create a new text element and add it to the page
        Dim text As New PdfTextElement(0, 0, _
            SelectPdf.Samples.Helper.SomeVeryLongText(), font)
        page.Add(text)

        ' save pdf document
        doc.Save(Response, False, "Sample.pdf")

        ' close pdf document
        doc.Close()
    End Sub

End Class