2011-05-26 48 views

回答

1

請參考this你的問題,這清除了你對你的問題的一些懷疑。

+0

感謝卡延的答覆,但我還沒有拿到代碼 – 2011-05-26 05:09:29

+0

@Sunil帕蒂爾,在我所提供的代碼由「寫在VB.net鏈接Stanav」。嘗試一次代碼。如果你想將你的代碼轉換爲C#,你可以使用 [1]:http://www.developerfusion.com/tools/convert/vb-to-csharp/#convert-code – 2011-05-26 05:14:28

+0

嗨stil我沒有得到代碼 – 2011-05-26 05:19:39

0

link for 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 
+0

OP明確要求解決方案「使用itextsharp」。您的解決方案適用於pdfsharp。你是否想暗示pdfsharp是itextsharp的一部分? – mkl 2016-09-05 10:54:47

相關問題