Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6728157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:08:10+00:00 2026-05-26T10:08:10+00:00

How to draw watermark text whose outline color is red and inner color is

  • 0

How to draw watermark text whose outline color is red and inner color is gray using iTextSharp

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:08:10+00:00Added an answer on May 26, 2026 at 10:08 am

    If you are using a watermark I’m assuming that you are talking about a PdfStamper. If so, once you’ve got a raw PdfContentByte using either GetOverContent() or GetUnderContent() there’s just a couple of properties that you need to set.

    • PdfContentByte.SetLineWidth(single) – set the stroke thickness
    • PdfContentByte.SetColorFill(BaseColor.GRAY) – set the fill color. You can also use any of the other color methods such as SetRGBColorFill() or SetCMYKColorFill()
    • PdfContentByte.SetColorStroke(BaseColor.RED) – set the stroke color
    • PdfContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE) – flag that you want text to be draw with both a fill and a stroke

    Below is a full working WinForms app targetting iTextSharp 5.1.1.0 that puts it all together. You should be able to move this to ASP.Net fairly easily as well as convert it to C# if needed.

    Option Explicit On
    Option Strict On
    
    Imports iTextSharp.text
    Imports iTextSharp.text.pdf
    Imports System.IO
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ''//Our sample files
            Dim InputFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test.pdf")
            Dim OutputFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test_W_Watermark.pdf")
    
            ''//Create our input file to watermark later, nothing special here
            Using FS As New FileStream(InputFile, FileMode.Create, FileAccess.Write, FileShare.Read)
                Using Doc As New Document(PageSize.LETTER)
                    Using W = PdfWriter.GetInstance(Doc, FS)
                        Doc.Open()
    
                        Doc.Add(New Paragraph("This is a test"))
    
                        Doc.Close()
                    End Using
                End Using
            End Using
    
    
            ''//Watermark the file that we create above
    
            ''//Bind a reader to our input file
            Dim R As New PdfReader(InputFile)
            ''//Create our output file stream
            Using FS As New FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.Read)
                ''//Bind a stamper to our output file stream
                Using stamper As New PdfStamper(R, FS)
                    ''//Grab the raw content byte to draw with
                    Dim cb = stamper.GetOverContent(1)
    
                    ''//Flag that we are starting text commands
                    cb.BeginText()
    
                    ''//Set the stroke width
                    cb.SetLineWidth(2)
    
                    ''//Set the fill (inner) color for the font
                    cb.SetColorFill(BaseColor.GRAY)
    
                    ''//Set the stroke (outer) color for the font
                    cb.SetColorStroke(BaseColor.RED)
    
                    ''//Flag that when drawing text the system should use both a fill and a stroke
                    cb.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE)
    
                    ''//Set a font to draw with
                    cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 50)
    
                    ''//Tell the system to start drawing at the center of the first page
                    cb.SetTextMatrix(R.GetPageSize(1).Width / 2, R.GetPageSize(1).Height / 2)
    
                    ''//Draw the actual text
                    cb.ShowText("Hello")
    
                    ''//Flag that we are done drawing text
                    cb.EndText()
                End Using
            End Using
            Me.Close()
        End Sub
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I draw the text using CTFramesetter, I have set kCTParagraphStyleSpecifierParagraphSpacing , kCTParagraphStyleSpecifierLineSpacing , kCTParagraphStyleSpecifierParagraphSpacingBefore
I want to draw a red box with values inside it (like a watermark)
I draw a triangle using line. How can I fill color on it? So
I draw an arc using onDraw(canvas) : @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
Why draw operation in android canvas are using float instead of int for (x,y)?
I draw an triangle using these piece of code CGPoint center; center = CGPointMake(x1,
I draw a bitmap onto a canvas using the following call: _playerImage = BitmapFactory.decodeResource(getResources(),
I want to Draw a hyper Link in C# using stringbuilder when i create
Draw rectangle using C# and I need to draw the arc in every edges
Mission: Draw two lines with different color on one graph with automatic cliping, by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.