watermarkPdf

watermarkPdf

ADVANCED / PREMIUM BASIC

Inserts a watermark into a PDF document.

Description
public watermarkPdf (string $source, string $target, [string $type, array $options])

This method allows you to insert a watermark image or text in a PDF document.

Parameters

source

Path to the PDF document.

target

Path to the resulting watermarked document.

type

Watermark type: 'text' or 'image'.

options

The possible keys and values are (required options are shown with yellow background):

key Type Description
annotations bool Import annotations (links, comments and others). False as default.

If type is 'image':

Key Type Description
image string Path to the watermark image.
positionX int X-asis position (page center as default).
positionY int Y-asis position (page center as default).
opacity float Decimal number between 0 and 1(optional), if not set defaults to 0.5.
height int Height value (proportional).
width int Width value (proportional).

If type is 'text':

Key Type Description
text string The string of text used for watermarking.
positionX int X-asis position (page center as default).
positionY int Y-asis position (page center as default).
opacity float Decimal number between 0 and 1(optional), if not set defaults to 0.5.
font string The font-family. It must be installed in the OS.
size int Font size.
color string RGB: array(r, g, b) (array(255, 255, 255)).
Code samples

Example #1

Example #2