logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
paleise  
#1 Posted : Monday, February 11, 2019 9:26:36 AM(UTC)
paleise

Rank: Advanced Member

Groups: Registered
Joined: 10/13/2017(UTC)
Posts: 32
Germany
Location: Freiburg

Thanks: 1 times
Hi,
is it possible to set a watermark in pdf document on runtime?

Thanks for your time!

Regards
Peter
Paul Rayman  
#2 Posted : Tuesday, February 12, 2019 7:59:00 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 724

Thanks: 1 times
Was thanked: 87 time(s) in 86 post(s)
Well.. yes. It is possible.

In the current version you may get access to annotations through page.Dictionary["Annots"] property and form Watermark annotation. But you need to know PDF specification to do that.

I can suggest you to try Pdfium.Net SDK ver. 4.0 release candidate.
You can download it here
https://forum.patagames.com/posts/m1578-Version-4-0-2704-was-released-on-March-06--2019#post1578


PdfAnnotation were addded in this version of SDK. So that the Watermark can be added as following

Code:

var doc = PdfDocument.Load(...);
var page = doc.Pages[0];
if(page.Annots == null)
   page.CreateAnnotations();

var txt = PdfTextObject.Create("This is my watermark", 0, 0, PdfFont.CreateStock(doc, FontStockNames.Arial), 35);
page.Annots.Add(new PdfWatermarkAnnotation(page, txt));

page.Dispose(); //To force the page to reload and apply changes in the PDF viewer

Edited by user Wednesday, March 6, 2019 3:19:56 AM(UTC)  | Reason: Not specified

Users browsing this topic
Similar Topics
How to add watermark to all pages (Common Questions)
by Miralon 6/28/2017 1:33:14 AM(UTC)
Adding watermark on printing (FAQ)
by Paul Rayman 5/21/2017 7:48:51 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.