With linked images, you can direct users to a URL when they click the image. This article will show you how to create image hyperlinks in a Word document by using Spire.Doc.

Step 1: Create a Word document, add a section and a paragraph.

Document doc = new Document();
Section section = doc.AddSection();
Paragraph paragraph = section.AddParagraph();

Step 2: Load an image to a DocPicture object.

DocPicture picture = new DocPicture(doc);
picture.LoadImage(Image.FromFile("logo.png"));

Step 3: Add an image hyperlink to the paragraph.

paragraph.AppendHyperlink("www.e-iceblue.com", picture, HyperlinkType.WebLink);

Step 4: Save the file.

doc.SaveToFile("output.docx", FileFormat.Docx);

Output:

Create an Image Hyperlink in Word in C#, VB.NET

Full Code:

[C#]
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using System.Drawing;
namespace CreateLink
{
    class Program
    {

        static void Main(string[] args)
        {

            Document doc = new Document();
            Section section = doc.AddSection();

            Paragraph paragraph = section.AddParagraph();
            Image image = Image.FromFile("logo.png");
            DocPicture picture = new DocPicture(doc);
            picture.LoadImage(image);
            paragraph.AppendHyperlink("www.e-iceblue.com", picture, HyperlinkType.WebLink);

            doc.SaveToFile("output.docx", FileFormat.Docx);
        }
    }
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields
Imports System.Drawing
Namespace CreateLink
	Class Program

		Private Shared Sub Main(args As String())

			Dim doc As New Document()
			Dim section As Section = doc.AddSection()

			Dim paragraph As Paragraph = section.AddParagraph()
			Dim image__1 As Image = Image.FromFile("logo.png")
			Dim picture As New DocPicture(doc)
			picture.LoadImage(image__1)
			paragraph.AppendHyperlink("www.e-iceblue.com", picture, HyperlinkType.WebLink)

			doc.SaveToFile("output.docx", FileFormat.Docx)
		End Sub
	End Class
End Namespace

Get Text within a Bookmark in C#, VB.NET

2018-01-03 08:44:50 Written by Koohji

Spire.Doc supports to retrieve, replace and delete bookmark content of a specified bookmark. This article will show you how we can get the plain text within a bookmark by using Spire.Doc with C# and VB.NET.

Step 1: Create a Document instance, and load a sample Word document.

Document doc = new Document();
doc.LoadFromFile("Bookmark.docx");

Step 2: Creates a BookmarkNavigator instance to access the bookmark.

BookmarksNavigator navigator = new BookmarksNavigator(doc);

Step 3: Locate a specific bookmark by bookmark name. Call the method GetBookmarkContent to get content within the bookmark.

navigator.MoveToBookmark("bookmark_1");
TextBodyPart textBodyPart = navigator.GetBookmarkContent();

Step 4: Iterate through the items in the bookmark content to get the plain, unformatted text of the bookmark.

string text = null;
foreach (var item in textBodyPart.BodyItems)
{
    if (item is Paragraph)
    {
        foreach (var childObject in (item as Paragraph).ChildObjects)
        {
            if (childObject is TextRange)
            {
                text += (childObject as TextRange).Text;
            }
        }
    }
}

Result:

Get Text within a Bookmark in C#, VB.NET

Full Code:

[C#]
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using System;
namespace GetText
{
    class Program
    {

        static void Main(string[] args)
        {

            Document doc = new Document();
            doc.LoadFromFile("Bookmark.docx");

            BookmarksNavigator navigator = new BookmarksNavigator(doc);
            navigator.MoveToBookmark("bookmark_1");
            TextBodyPart textBodyPart = navigator.GetBookmarkContent();

            string text = null;
            foreach (var item in textBodyPart.BodyItems)
            {
                if (item is Paragraph)
                {
                    foreach (var childObject in (item as Paragraph).ChildObjects)
                    {
                        if (childObject is TextRange)
                        {
                            text += (childObject as TextRange).Text;
                        }
                    }
                }
            }
            Console.WriteLine(text);
        }
    }
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields
Namespace GetText
	Class Program

		Private Shared Sub Main(args As String())

			Dim doc As New Document()
			doc.LoadFromFile("Bookmark.docx")

			Dim navigator As New BookmarksNavigator(doc)
			navigator.MoveToBookmark("bookmark_1")
			Dim textBodyPart As TextBodyPart = navigator.GetBookmarkContent()

			Dim text As String = Nothing
			For Each item As var In textBodyPart.BodyItems
				If TypeOf item Is Paragraph Then
					For Each childObject As var In TryCast(item, Paragraph).ChildObjects
						If TypeOf childObject Is TextRange Then
							text += TryCast(childObject, TextRange).Text
						End If
					Next
				End If
			Next
			Console.WriteLine(text)
		End Sub
	End Class
End Namespace

With the help of Spire.Presentation, we can easily set the border type and color of a whole table on the presentation slides. This article will focus on demonstrating how to set the border for the table in C#.

Firstly, view the 12 border types for the table on PowerPoint file:

Set the border type and color for the table on Presentation slides

How to set the border type and color for an existing table on presentation slide:

//create a presentation document and load the file from disk
Presentation presentation = new Presentation();
presentation.LoadFromFile("Sample.pptx");

//get the table from the first slide of the sample document
ISlide slide = presentation.Slides[0];
ITable table = slide.Shapes[1] as ITable;
     
//set the border type as Inside and the border color as blue
table.SetTableBorder(TableBorderType.Inside, 1, Color.Blue);

//save the document to file
presentation.SaveToFile("Insideborder.pptx", FileFormat.Pptx2010);

Effective screenshot after set the border type for an existing table on presentation slide:

Set the border type and color for the table on Presentation slides

How to set the border type and color for newly added tables on presentation slide:

using Spire.Presentation;
using System;

namespace Set_border_type_and_color
{

    class Program
    {
        static void Main(string[] args)
        {

            //create a presentation document 
            Presentation presentation = new Presentation();

            //set the table width and height for each table cell
            double[] tableWidth = new double[] { 100, 100, 100, 100, 100 };
            double[] tableHeight = new double[] { 20, 20 };

            //traverse all the border type of the table
            foreach (TableBorderType item in Enum.GetValues(typeof(TableBorderType)))

            //add a table to the presentation slide with the setting width and height
            {
                ITable itable = presentation.Slides.Append().Shapes.AppendTable(100, 100, tableWidth, tableHeight);

                //add some text to the table cell
                itable.TableRows[0][0].TextFrame.Text = "Row";
                itable.TableRows[1][0].TextFrame.Text = "Column";

                //set the border type, border width and the border color for the table
                itable.SetTableBorder(item, 1.5, Color.Red);

            }

            //save the document to file
            presentation.SaveToFile("Addtablewithborder.pptx", FileFormat.Pptx2010);

        }
    }
}

Set the border type and color for the table on Presentation slides

page 182