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

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
paleise  
#1 Posted : Monday, February 11, 2019 6:26:36 AM(UTC)
Quote
paleise

Rank: Advanced Member

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

Thanks: 3 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 4:59:00 AM(UTC)
Quote
Paul Rayman

Rank: Administration

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

Thanks: 10 times
Was thanked: 133 time(s) in 130 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 12:19:56 AM(UTC)  | Reason: Not specified

Quick Reply Show Quick Reply
Users browsing this topic
Guest
Similar Topics
Is It Possible to Watermark each PDF I Sold with the Customer's Name? (Common Questions)
by michel295 6/22/2024 5:45:37 AM(UTC)
Discuss How you can Customize the Font, Size, and Color of the Watermark to Apply to a PDF Document. (Common Questions)
by michel295 6/13/2024 11:34:55 PM(UTC)
Image Watermark (Bug Report & Technical Support)
by eltons 6/25/2019 5:49:10 AM(UTC)
How to add watermark to all pages (Common Questions)
by Miralon 6/27/2017 10:33:14 PM(UTC)
Adding watermark on printing (FAQ)
by Paul Rayman 5/21/2017 4:48:51 PM(UTC)
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.