GroupDocsGists
10/19/2017 - 11:19 AM

RenderAsPdfWithWatermarkFont.cs

// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET
// Create/initialize image handler 
ViewerImageHandler imageHandler = new ViewerImageHandler(Utilities.GetConfigurations());

// Set watermark properties
Watermark watermark = new Watermark(WatermarkText);
watermark.Color = System.Drawing.Color.Blue;
watermark.Position = WatermarkPosition.Diagonal;
watermark.Width = 100;

// Set watermark font name which contains Japanese characters
watermark.FontName = "MS Gothic";

PdfFileOptions options = new PdfFileOptions();
options.Watermark = watermark;

// To Apply transformations on PDF file
// options.Transformations = Transformation.Rotate | Transformation.Reorder | Transformation.AddPrintAction;

// Call GetPdfFile to get FileContainer type object which contains the stream of pdf file.
FileContainer container = imageHandler.GetPdfFile(DocumentName, options);

//Change the extension of the file and assign to a string type variable filename
String filename = Path.GetFileNameWithoutExtension(DocumentName) + ".pdf";

//Save each image at disk
Utilities.SaveFile(filename, container.Stream);