iOS
ComPDFKit PDF SDK
Guides

Watermark

 

Adding a non-removable watermark to documents can discourage viewers from sharing your content or taking screenshots.

 

To access the list of watermarks, use function CPDFDocument::watermarks.

To add a watermark, use function CPDFDocument::addWatermark:.

To remove the watermark, use function CPDFDocument::removeWatermark:.

To update the watermark, use function CPDFDocument::updateWatermark.

 

How to generate a PDF with a watermark on all its pages using the CPDFDocument API:

 

NSURL *url = [NSURL fileURLWithPath:@""];
CPDFDocument *document = [[[CPDFDocument alloc] initWithURL:url] autorelease];

CPDFWatermark *watermark = [[[CPDFWatermark alloc] initWithDocument:document type:CPDFWatermarkTypeText] autorelease];
watermark.text = @"test";
watermark.scale = 2.0;
watermark.rotation = 45;
watermark.opacity = 0.6;
watermark.verticalPosition = CPDFWatermarkVerticalPositionCenter;
watermark.horizontalPosition = CPDFWatermarkHorizontalPositionCenter;
watermark.tx = 0.0;
watermark.ty = 0.0;
[document addWatermark:watermark];

NSURL *surl = [NSURL fileURLWithPath:@""];
[document writeToURL:surl];