Imports Aspose.Pdf
Imports System.IO
Public Class test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim pdf_memoryStream As New MemoryStream
Dim ms As New IO.MemoryStream
Dim pdf_byteArray As Byte()
' commenting out the license will produce the first pdf page as an evaluation page but it's missing when there's a license
Dim license As New Aspose.Pdf.License
license.SetLicense("Aspose.Pdf.lic")
pdf_memoryStream = GenerateDocument("THIS IS THE FIRST PDF PAGE")
ms = GenerateDocument("THIS IS THE SECOND PDF PAGE")
pdf_memoryStream = ConcatenatePdf(pdf_memoryStream, ms)
ms = GenerateDocument("THIS IS THE THIRD PDF PAGE")
pdf_memoryStream = ConcatenatePdf(pdf_memoryStream, ms)
pdf_byteArray = pdf_memoryStream.ToArray()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.OutputStream.Write(pdf_byteArray, 0, pdf_byteArray.Length)
Response.End()
End Sub
Public Shared Function ConcatenatePdf(ByVal firstMemoryStream As Stream, secondMemoryStream As Stream) As MemoryStream
Dim pdfMainDocument As New Document(firstMemoryStream)
Dim pdfDocument As New Document(secondMemoryStream)
Dim ms As New MemoryStream()
pdfMainDocument.Pages.Add(pdfDocument.Pages)
pdfMainDocument.Save(ms)
Return ms
End Function
Public Shared Function GenerateDocument(ByVal message As String) As MemoryStream
Dim pdf As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()
Dim ms As New MemoryStream
Dim sec1 As Aspose.Pdf.Generator.Section = pdf.Sections.Add()
sec1.Paragraphs.Add(New Aspose.Pdf.Generator.Text(message))
pdf.Save(ms)
Return ms
End Function
End Class