0

我有一张图片,我想将其用作我使用下面的代码生成的 PDF 的标题。是否有可能做到这一点?谢谢!

   Dim Doc1 As New Document
    Dim path As String = "" + Session("Username") + "\"
    If (Not System.IO.Directory.Exists(path)) Then

        System.IO.Directory.CreateDirectory(path)
    End If
    Dim myUniqueFileName = String.Format("{0}.pdf", random)
    Dim pdfWrite As PdfWriter = PdfWriter.GetInstance(Doc1, New FileStream(path & myUniqueFileName, FileMode.Create))
    Dim ev As New itsEvents
    pdfWrite.PageEvent = ev

    Doc1.Open()
    Dim test As String
    test = Session("PDF")
    Doc1.Add(New Paragraph(test))

    Doc1.Close()
End Sub
Public Class itsEvents
    Inherits PdfPageEventHelper
    Public Overrides Sub OnStartPage(ByVal writer As iTextSharp.text.pdf.PdfWriter, ByVal document As iTextSharp.text.Document)
        Dim ch As New Chunk("This is my header " & writer.PageNumber)
        document.Add(ch)
    End Sub
End Class
4

0 回答 0