Sample Code VB.NET
Imports SelectPdf Namespace Controllers Public Class PdfCompressionController Inherits Controller ' GET: PdfCompression Public Function Index() As ActionResult Return View() End Function <HttpPost> Public Function SubmitAction(collection As FormCollection) As ActionResult ' 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), collection("DdlPdfCompressionLevel"), 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, Helper.SomeVeryLongText(), font) page.Add(text) ' save pdf document Dim pdf As Byte() = doc.Save() ' close pdf document doc.Close() ' return resulted pdf document Dim fileResult As FileResult = New FileContentResult(pdf, "application/pdf") fileResult.FileDownloadName = "Document.pdf" Return fileResult End Function End Class End Namespace