Imports ColorCode.Compilation.Languages

Public Class pdf_html_element
    Inherits System.Web.UI.Page

    Protected Sub BtnCreatePdf_Click(sender As Object, e As EventArgs)

        Dim renderingEngine As RenderingEngine = CType([Enum].Parse(GetType(RenderingEngine), DdlRenderingEngine.SelectedValue, True), RenderingEngine)
        ' create a new pdf document
        Dim doc As New PdfDocument()

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

        ' create html element 
        Dim html As New PdfHtmlElement(TxtUrl.Text)
        html.RenderingEngine = renderingEngine
        html.CefEnginePath = Server.MapPath(ConfigurationManager.AppSettings("CefEnginePath"))

        ' add the html element to the document
        page.Add(html)

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

        ' close pdf document
        doc.Close()
    End Sub

End Class