PdfRpt.Core.Helper.DiagonalWatermarkManager.ApplyWatermark C# (CSharp) Method

ApplyWatermark() public method

Apply Watermark to the added templates
public ApplyWatermark ( Document document ) : void
document iTextSharp.text.Document PDF Document
return void
        public void ApplyWatermark(Document document)
        {
            var diagonalWatermark = PageSetup.DiagonalWatermark;
            if (diagonalWatermark == null) return;

            var textAngle = (float)getHypotenuseAngleInDegreesFrom(document.PageSize.Height, document.PageSize.Width);
            var text = diagonalWatermark.Text;

            if (diagonalWatermark.RunDirection == null)
                diagonalWatermark.RunDirection = PdfRunDirection.LeftToRight;

            if (diagonalWatermark.RunDirection == PdfRunDirection.RightToLeft)
                text = text.FixWeakCharacters();

            var phrase = diagonalWatermark.Font.FontSelector.Process(text.ToSafeString());

            ColumnText.ShowTextAligned(
                _watermarkTemplate,
                Element.ALIGN_CENTER,
                phrase,
                document.PageSize.Width / 2,
                document.PageSize.Height / 2,
                textAngle,
                (int)diagonalWatermark.RunDirection,
                0);
        }