Rank: Advanced Member
Groups: Registered
Joined: 10/13/2017(UTC) Posts: 52  Location: Freiburg Thanks: 3 times
|
Hi, is it possible to set a watermark in pdf document on runtime?
Thanks for your time!
Regards Peter
|
|
|
|
|
|
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#post1578PdfAnnotation 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
|
|
|
|
|
|
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.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close