Add-PDFWatermark

Adds watermarks to pdf files.

Syntax

1
Add-PDFWatermark -Path <string> -Text <string> [-Fontsize <int>] [-Angle <double>] [-Color <string>] [-Opacity <int>] [-VerticalAlignment <string>] [-HorinzontalAlignment <string>] [<CommonParameters>]

Parameters

Type

Name

Description

Default value

Optional

String

Path

Path to the pdf file for adding the watermark.

no

String

Text

Watermark text that should appear on the pdf file.

no

Integer

Fontsize

Size of the watermark.

50

yes

Double

Angle

Rotation of the watermark in degrees. (0 - 360)

315

yes

String

Color

Color of the watermark.

“Red”

yes

Integer

Opacity

Opacity of the watermark. (0 - 100)

50

yes

String

VerticalAlignment

Vertical position of the watermark on the pdf file. (‘Top’, ‘Center’, ‘Bottom’)

“Center”

yes

String

HorizontalAlignment

Horizontal position of the watermark on the pdf file. (‘Left’, ‘Center’, ‘Right’)

“Center”

yes

Return type

Bool ← on success the cmdlet returns $true otherwise $false. On failure the Exception/ErrorMessage can be accessed using $Error.

Remarks

For PDF files with multiple pages, the watermark is applied to each page.
The default font is Arial and fontstyle is Regular.
Vertical and horizontal alignment have a default offset of 3% of the page size from the border if not placed in the center.
The -Color argument accepts all values of KnownColor values.

Examples

Adding a tilted watermark to the center of the pdf

Add-PDFWatermark -Path '$/Designs/Test.pdf' -Text 'Final' -Fontsize 20 -Angle 45 -Color 'Red' -Opacity 25 -VerticalAlignment 'Center' -HorizontalAlignment 'Center'

Error handling, analyze why watermark could not be added using $Error:

1
2
3
4
5
$result = Add-PDFWatermark -Path '$/Not/Existing/File.pdf' -Text 'Final'

if(-not $result){
    $Error[0].Exception #Returns: "File '$/Not/Existing/File.pdf' not found!"
}