You are viewing limited content. For full access, please sign in.

Question

Question

Tag Watermark missing on PDF generated via SDK

asked on October 17, 2018

Hello,

I'm sure I'm just missing something simple, but the SDK code I've been using to generate PDF attachments doesn't seem to include any watermarks associated with tags assigned to the document.

I am rendering annotations as images and everything else is working as expected, but the resulting PDF has no watermark so I must be missing something in my code.

I know I can use WatermarkSpecification to add watermarks based on the TagWatermark attributes, but I was hoping there is a more direct way to tell the SDK to include them in the exported PDF.

1 0

Answer

SELECTED ANSWER
replied on October 19, 2018

I'm still not sure if there's a better way to do this, and if someone has one I'll select a different answer, but for now I came up with some fairly compact code to get the watermarks added.

Basically I had to create a List of WatermarkSpecifications, retrieve a TagWatermarkCollection, loop through each TagWatermark, add a WatermarkSpecification to the list with the attributes from each TagWatermark, then add that list to the document exporter.

// Build a list of watermarks and add tag watermarks associated with the document
List<WatermarkSpecification> watermarks = new List<WatermarkSpecification>();
foreach(TagWatermark w in doc.GetTagWatermarks()){
    watermarks.Add(new WatermarkSpecification(w.WatermarkText,w.WatermarkTextSize,w.WatermarkRotation,w.WatermarkPosition,String.Empty,0,String.Empty,0,w.WatermarkIntensity));
}

// Initialize document exporter
DocumentExporter dExp = new DocumentExporter();

// Configure document exporter settings
dExp.CompressionQuality = compression;
dExp.IncludeAnnotations = true;
dExp.BlackoutRedactions = true;
dExp.PageFormat = DocumentPageFormat.Jpeg;
dExp.Watermarks = watermarks; // Add watermarks to exporter

 

1 0
replied on October 10, 2023

Thank you for this posting. Very helpful!

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.