如何在asp.net中使用itextsharp在pdf或现有的pdf上显示水印文本

| 帮我在asp.net中使用itextsharp在pdf上显示水印文本 谢谢, 苏尼尔     
已邀请:
将其作为您的问题,以免除您对您的问题的某些疑问。     
pdfsharp dll的链接 与pdfsharp \'导入此
    Imports System.IO
    Imports PdfSharp.Pdf
    Imports PdfSharp.Pdf.IO
    Imports PdfSharp.Drawing

    Dim doc = ReturnCompatiblePdf(path_of_pdf_file)
    Dim document As New PdfDocument
    document = PdfReader.Open(doc, PdfDocumentOpenMode.Modify)
    Dim watermark As String = \"This is my watermark\"

    For Each page_ As PdfPage In document.Pages

        Dim gfx As XGraphics = XGraphics.FromPdfPage(page_, XGraphicsPdfPageOptions.Append)
        Dim fontx As New XFont(\"Trebuchet MS\", 8, FontStyle.Bold)
        Dim posx, posy As Double
        posx = (page_.Width.Value - watermark.Length) / 2
        posy = page_.Height.Value - 8
        gfx.TranslateTransform(posx, posy)
        gfx.DrawString(watermark, fontx, XBrushes.Black, New XPoint(1, 1), XStringFormats.Default)
    Next

    If File.Exists(save_path) = False Then
        document.Save(save_path)
    End If
    

要回复问题请先登录注册