Wednesday, February 3, 2010

Adding Watermark on Word file(C#)


public
{
Word.

void AddWatermark()Application wordApp = null;// applicationObject = application;

// object oname = applicationObject.GetType().InvokeMember("Name", BindingFlags.GetProperty, null, applicationObject, null);

{
wordApp = (Word.
}

{
Word.
doc.ActiveWindow.ActivePane.View.Type= Microsoft.Office.Interop.Word.


Word.
Word.

doc.Sections[1].Range.Select();
doc.ActiveWindow.ActivePane.View.SeekView = Word.
wmShape = mSelection.HeaderFooter.Shapes.AddTextEffect(Office.
wmShape.Select(

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddPicture(FileName:= "C:\25.jpg", LinkToFile:=False, SaveWithDocument:=True).Select*/
if (ThisApplication is Word.Application)Application)ThisApplication;if (wordApp != null)Document doc = wordApp.ActiveDocument;WdViewType.wdPrintView;Selection mSelection = wordApp.Selection;ShapewmShape;object anchor =Missing.Value;WdSeekView.wdSeekCurrentPageHeader;MsoPresetTextEffect.msoTextEffect1, "WaterMARK""Times New Roman", 1, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse, 0, 0, ref anchor);refanchor);/*ActiveDocument.Sections(1).Range.Select
wmShape.Name =
wmShape.TextEffect.NormalizedHeight = Office.
wmShape.Line.Visible = Office.
wmShape.Fill.Visible = Office.
wmShape.Fill.Solid();
wmShape.Fill.ForeColor.RGB = (
wmShape.Fill.Transparency = 0.5f;

"PowerPlusWaterMarkObject1";MsoTriState.msoFalse;MsoTriState.msoFalse;MsoTriState.msoTrue;int)Word.WdColor.wdColorGray25;//wmShape.Rotation = 3.0f;
wmShape.LockAspectRatio = Office.
wmShape.Height = wordApp.InchesToPoints(0.82f);
wmShape.Width = wordApp.InchesToPoints(0.64f);
wmShape.WrapFormat.Side = Word.
wmShape.WrapFormat.Type = Word.
wmShape.RelativeHorizontalPosition = Word.
wmShape.RelativeVerticalPosition = Word.
wmShape.Left = (
wmShape.Top = (
doc.ActiveWindow.View.SeekView = Word.


MsoTriState.msoTrue;WdWrapSideType.wdWrapBoth;WdWrapType.wdWrapNone;WdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin;WdRelativeVerticalPosition.wdRelativeVerticalPositionMargin;float)Word.WdShapePosition.wdShapeCenter;float)Word.WdShapePosition.wdShapeTop;WdSeekView.wdSeekMainDocument;//rng.InsertFile("", ref Missing.Value, Missing.Value, Missing.Value, Missing.Value);

//wordApp.Selection.InlineShapes.AddPicture("C://dance.gif", ref false, ref true, ref doc.Paragraphs[2].Range);
}

No comments:

Post a Comment