The sample demonstrates how to insert watermark into Word document.
private void button1_Click(object sender, EventArgs e)
{
//Create word document
Document document = new Document();
InsertWatermark(document);
//Save doc file.
document.SaveToFile("Sample.doc",FileFormat.Doc);
//Launching the MS Word file.
WordDocViewer("Sample.doc");
}
private void InsertWatermark(Document document)
{
Paragraph paragraph = document.AddSection().AddParagraph();
paragraph.AppendText("The sample demonstrates how to insert a watermark into a document.");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph.AppendText("Microsoft Word is a word processor designed by Microsoft. It was first released in 1983 under the name Multi-Tool Word for Xenix systems. Subsequent versions were later written for several other platforms including IBM PCs running DOS (1983), the Apple Macintosh (1984), the AT&T Unix PC (1985), Atari ST (1986), SCO UNIX, OS/2, and Microsoft Windows (1989).");
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph.AppendText("Spire.Doc can generate, modify, convert, render and print documents without utilizing Microsoft Word.");
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph.AppendText("The sample demonstrates how to insert a watermark into a document.");
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph.AppendText("Microsoft Word is a word processor designed by Microsoft. It was first released in 1983 under the name Multi-Tool Word for Xenix systems. Subsequent versions were later written for several other platforms including IBM PCs running DOS (1983), the Apple Macintosh (1984), the AT&T Unix PC (1985), Atari ST (1986), SCO UNIX, OS/2, and Microsoft Windows (1989).");
paragraph = document.Sections[0].AddParagraph();
paragraph = document.Sections[0].AddParagraph();
paragraph.AppendText("Spire.Doc can generate, modify, convert, render and print documents without utilizing Microsoft Word.");
TextWatermark txtWatermark = new TextWatermark();
txtWatermark.Text = "Watermark Demo";
txtWatermark.FontSize = 90;
txtWatermark.Layout = WatermarkLayout.Diagonal;
document.Watermark = txtWatermark;
}
private void WordDocViewer(string fileName)
{
try
{
System.Diagnostics.Process.Start(fileName);
}
catch { }
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
'Create word document
Dim document_Renamed As New Document()
InsertWatermark(document_Renamed)
'Save doc file.
document_Renamed.SaveToFile("Sample.doc",FileFormat.Doc)
'Launching the MS Word file.
WordDocViewer("Sample.doc")
End Sub
Private Sub InsertWatermark(ByVal document_Renamed As Document)
Dim paragraph_Renamed As Paragraph = document_Renamed.AddSection().AddParagraph()
paragraph_Renamed.AppendText("The sample demonstrates how to insert a watermark into a document.")
paragraph_Renamed.ApplyStyle(BuiltinStyle.Heading2)
Dim txtWatermark As New TextWatermark()
txtWatermark.Text = "Watermark Demo"
txtWatermark.FontSize = 90
txtWatermark.Layout = WatermarkLayout.Diagonal
document_Renamed.Watermark = txtWatermark
End Sub
Private Sub WordDocViewer(ByVal fileName As String)
Try
Process.Start(fileName)
Catch
End Try
End Sub