Example #1
0
        private void MakePdwWatermark(Microsoft.Office.Interop.Word.Application wApp, TemplateType templateType,
                                      Core.InternalBookmarkDomain firstDomain)
        {
            try
            {
                Microsoft.Office.Interop.Word.Selection Selection = wApp.Selection;
                Microsoft.Office.Interop.Word.Shape     wmShape;
                Selection.Select();

                // set focus on header to put watermark
                wApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageHeader;

                //Create the watermar shape
                wmShape = Selection.HeaderFooter.Shapes.AddTextEffect(
                    Microsoft.Office.Core.MsoPresetTextEffect.msoTextEffect1,
                    GenPdwWatermarkValue(templateType, firstDomain),
                    "Times New Roman", 1,
                    Microsoft.Office.Core.MsoTriState.msoFalse,
                    Microsoft.Office.Core.MsoTriState.msoFalse,
                    0, 0);

                //Set all of the attributes of the watermark
                wmShape.Select();
                wmShape.Name = PdwWaterMarkName;
                wmShape.TextEffect.NormalizedHeight = Microsoft.Office.Core.MsoTriState.msoFalse;
                wmShape.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
                wmShape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                wmShape.Fill.Solid();
                wmShape.Fill.ForeColor.RGB = (int)Microsoft.Office.Interop.Word.WdColor.wdColorGray25;
                wmShape.Fill.Transparency  = 0.5f;
                wmShape.Rotation           = GenPdwWatermarkRotation(templateType);
                wmShape.LockAspectRatio    = Microsoft.Office.Core.MsoTriState.msoTrue;
                wmShape.Height             = GenPdwWatermarkHeight(wApp, templateType);
                wmShape.Width = wApp.InchesToPoints(7.64f);
                wmShape.WrapFormat.AllowOverlap    = -1;                                                  //true
                wmShape.WrapFormat.Side            = Microsoft.Office.Interop.Word.WdWrapSideType.wdWrapBoth;
                wmShape.WrapFormat.Type            = Microsoft.Office.Interop.Word.WdWrapType.wdWrapNone; //3
                wmShape.RelativeHorizontalPosition =
                    Microsoft.Office.Interop.Word.WdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin;
                wmShape.RelativeVerticalPosition =
                    Microsoft.Office.Interop.Word.WdRelativeVerticalPosition.wdRelativeVerticalPositionMargin;
                wmShape.Left = (float)Microsoft.Office.Interop.Word.WdShapePosition.wdShapeCenter;
                wmShape.Top  = (float)Microsoft.Office.Interop.Word.WdShapePosition.wdShapeCenter;

                //set focus back to document
                wApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;
            }
            catch { }
        }