How to Start Convert PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

VB.NET PDF Watermark Component
How to add text, image watermark to existing pdf file using visual basic .net


An Excellent PDF Control Allows vb.net Developers to add or delete watermark to PDF File in VB.NET





In this VB.NET tutorial, you will learn how to use VB.NET to add, edit text or image watermarks on PDF pages in your .NET Windows Forms application.

  • Add, insert text, image watermark to pages
  • Read, extract all existing text, image watermark from PDF pages
  • Remove, delete existing text, image watermarks from PDF pages

How to add, remove watermarks on PDF pages using VB.NET

  1. Download XDoc.PDF watermark VB.NET library
  2. Install VB library to insert, read, delete watermark from PDF pages
  3. Step by Step Tutorial










  • Professional PDF SDK for Visual Studio .NET, which able to add watermark in VB.NET class
  • Advanced PDF edit control and component for modify watermark in both VB.NET WinForms
  • For C# developer, view tutorial at How to add, remove, edit text, image watermark on PDF in C#
  • Free online sample code for quick evaluation in Visual Basic .NET framework for PDF watermark
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • Easy to add/remove watermark to/from PDF page online in browser in ASP.NET web project
  • Support to copy a PDF watermark to another PDF file page in .NET framework
  • Support to add different watermark to PDF file.




A watermark is text or an image that is displayed either in front of or behind existing PDF document content. For example, you could create and add a "Confidential" text watermark to PDF pages with sensitive information. You can add multiple watermarks to a PDF file, but you must add each watermark separately. You can specify the page or range of pages on which each watermark appears.



asp.net core open word document, asp.net tiff viewer control, asp.net display image from byte array, asp.net core pdf preview, asp.net c# view pdf, how to write pdf file in asp.net c#, c# mvc website pdf file in stored in byte array display in browser.





Watermark property settings in vb.net


Text watermark supports the following property settings:


  1. Text message: the text watermark message
  2. Text font style: the text font style
  3. Text color: the text font color
  4. Text alignment: the text watermark alignment
  5. IsAbovePage: the text watermark will be displayed above pdf page content or below the content
  6. Rotate: text rotation value
  7. Opacity: the text transparency
  8. PageRangeOptions: list of pages where the watermark will be applied.




Image watermark supports the following property settings:


  1. Image file resource: the Bitmap object includes watermark image data
  2. IsAbovePage: the image watermark will be displayed above pdf page content or below the content
  3. Opacity: the image transparency
  4. PageRangeOptions: list of pages where the watermark will be applied.






VB.NET add watermark to PDF document



The following content will explain how to add text watermark, and image watermark to pdf document with property settings.









Add text watermark to a PDF document object using vb.net


The following vb.net example source code shows how to add two text watermarks to a PDF document. One watermark is added to each odd pages, and the other watermark is added to each even pages.



Dim inputFilePath As String = "C:\1.pdf"
Dim outputFilePath As String = "C:\1_watermk.pdf"

' open a PDF file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)

Dim resWatermark As PDFWatermarkTextRes = New PDFWatermarkTextRes("Confidential", New Font("Arial", 72.0F, FontStyle.Regular), Color.Black, WatermarkTextAlignment.Center)

' define a watermark setting
Dim watermark1 As PDFPageWatermark = New PDFPageWatermark(resWatermark)
watermark1.IsAbovePage = False
watermark1.Rotate = -45.0F
watermark1.Opacity = 0.2F

' define page range all odd pages
Dim pageRange1 As PageRangeOptions = New PageRangeOptions()
pageRange1.AllPages = True
pageRange1.Subset = PageRangeSubset.Odd

' apply watermark settings to all odd pages
PDFPageFieldHandler.ApplyWatermark(doc, watermark1, pageRange1)

' define a watermark setting
Dim watermark2 As PDFPageWatermark = New PDFPageWatermark(resWatermark)
watermark2.IsAbovePage = False
watermark2.Rotate = 45.0F
watermark2.Opacity = 0.2F

' define page range all even pages
Dim pageRange2 As PageRangeOptions = New PageRangeOptions()
pageRange2.AllPages = True
pageRange2.Subset = PageRangeSubset.Even

' apply watermark settings to all even pages
PDFPageFieldHandler.ApplyWatermark(doc, watermark2, pageRange2)

doc.Save(outputFilePath)






Add image watermark to a PDF document object using vb.net


The following vb.net example source code shows how to add an image watermark to every pages in a PDF document.



Dim inputFilePath As String = "C:\1.pdf"
Dim outputFilePath As String = "C:\1_watermk.pdf"
Dim resImage As Bitmap = New Bitmap("C:\watermark.png")

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)

Dim resWatermark As PDFWatermarkImageRes = New PDFWatermarkImageRes(resImage)

' Define a watermark setting
Dim watermark As PDFPageWatermark = New PDFPageWatermark(resWatermark)
' Set watermark behind the page content.
watermark.IsAbovePage = False
' Set transparancy.
watermark.Opacity = 0.2F

' Define page range all pages
Dim pageRange As PageRangeOptions = New PageRangeOptions()
pageRange.AllPages = True
pageRange.Subset = PageRangeSubset.All

' Apply watermark settings to all odd pages
PDFPageFieldHandler.ApplyWatermark(doc, watermark, pageRange)

' Save file
doc.Save(outputFilePath)






VB.NET remove all page watermark settings in a PDF document object


The following vb.net example source code shows how to remove, delete all existing watermarks from a PDF document.



Dim inputFilePath As String = "C:\1_watermk.pdf"
Dim outputFilePath As String = "C:\output.pdf"

Dim doc As PDFDocument = New PDFDocument(inputFilePath)
PDFPageFieldHandler.RemoveWatermarks(doc)
doc.Save(outputFilePath)




VB.NET read, extract all page watermark settings from a PDF file


The following vb.net example source code shows how to read, display watermark properties.



Dim inputFilePath As String = "C:\1_watermk.pdf"

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)

' Get all Watermark settings in the document
Dim info As PDFPageWatermarkInfo = PDFPageFieldHandler.RetreiveWatermarks(doc)

' Get default setting for Watermark And Page Range
Dim defaultSetting As PDFPageWatermark = info.GetDefaultSetting()
Dim defaultPageRange As PageRangeOptions = info.GetDefaultPageRangeSettings()

' Number of watermark settings in the document.
Console.WriteLine("Watermark: {0}", info.Count)
' Show default watermark setting
Console.WriteLine("Is above page:         {0}", defaultSetting.IsAbovePage)
Console.WriteLine("Opacity:               {0}", defaultSetting.Opacity)
Console.WriteLine("Enable absolute scale: {0}", defaultSetting.EnableAbsoluteScale)
' Show all watermark settings in the document.
For Each setting As PDFPageWatermark In info.GetAllSettings()
    Console.WriteLine("Watermark Setting")
    Console.WriteLine("Is above page:         {0}", setting.IsAbovePage)
    Console.WriteLine("Rotate (in degree):    {0}", setting.Rotate)
    Console.WriteLine("Opacity:               {0}", setting.Opacity)
    Console.WriteLine("Enable absolute scale: {0}", setting.EnableAbsoluteScale)
    Console.WriteLine("Scale:                 {0}", setting.Scale)
    Console.WriteLine("Alignment")
    Console.WriteLine("Horizontal:            {0}; Margin: {1}", setting.HoriAlignment, setting.HoriMargin)
    Console.WriteLine("Vertical:              {0}; Margin: {1}", setting.VertAlignment, setting.VertMargin)
    Dim pageRange As PageRangeOptions = info.GetPageRangeOptions(setting)
    Console.WriteLine("Page Range Settings")
    Console.WriteLine("Is all page:           {0}", pageRange.AllPages)
    Console.WriteLine("Subset type:           {0}", pageRange.Subset.ToString())
    Console.WriteLine("Min. Page Number:      {0}", pageRange.MinPageNum)
    Console.WriteLine("Max. Page Number:      {0}", pageRange.MaxPageNum)
Next