SelectPdf for .NET - Convert Multiple Urls into the same Pdf Document - VB.NET / ASP.NET Sample

This sample shows how to convert 3 different urls to the same pdf document using SelectPdf Pdf Library for .NET.

Url 1: 

Url 2: 

Url 3: 



Sample Code Vb.Net



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 convert_multiple_urls_to_pdf
        Inherits System.Web.UI.Page

        Protected Sub BtnCreatePdf_Click(sender As Object, e As EventArgs)
            ' read parameters from the webpage
            Dim url1 As String = TxtUrl1.Text
            Dim url2 As String = TxtUrl2.Text
            Dim url3 As String = TxtUrl3.Text

            ' create a new pdf document 
            Dim doc As New PdfDocument()

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

            ' add the first url
            Dim html1 As New PdfHtmlElement(url1)
            Dim result As PdfRenderingResult = page.Add(html1)

            ' get the last page of the previous conversion
            Dim page2 As PdfPage = doc.Pages(result.PdfPageLastIndex)

            ' add the second url
            Dim html2 As New PdfHtmlElement(result.PdfPageLastRectangle.Left, _
                                            result.PdfPageLastRectangle.Bottom, url2)
            result = page2.Add(html2)

            ' get the last page of the previous conversion
            Dim page3 As PdfPage = doc.Pages(result.PdfPageLastIndex)

            ' add the third url
            Dim html3 As New PdfHtmlElement(result.PdfPageLastRectangle.Left, _
                                            result.PdfPageLastRectangle.Bottom, url3)
            result = page3.Add(html3)

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

            ' close pdf document
            doc.Close()

        End Sub
    End Class
End Namespace