Reputation: 1
Help me to display watermark text on pdf using itextsharp in asp.net Thanks, Sunil.
Upvotes: 0
Views: 2319
Reputation: 1
link for pdfsharp dll with pdfsharp 'import this
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
Upvotes: 0
Reputation: 11844
Refer this for your question which clears some doubt of u regarding your question.
Upvotes: 1