usmanazizgroupdocs
11/9/2016 - 3:12 PM

RenderDocumentAsPDFWithWatermark.cs

// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET
// get Configurations
ViewerConfig config = Utilities.GetConfigurations();

// create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);

// guid implies that unique document name 
string guid = DocumentName;

PdfFileOptions options = new PdfFileOptions(); 

// Set watermark properties
Watermark watermark = new Watermark("This is watermark text");
watermark.Color = Color.Red;
watermark.Position = (WatermarkPosition.Diagonal);
watermark.Width = 100 ;

options.Watermark = watermark;

// get file as pdf with print action
FileContainer container = htmlHandler.GetPdfFile(guid, options);

// save PDF file
Utilities.SaveFile(guid, container.Stream);