Skip to main content Skip to footer

Videos Home / Document Solutions Channel

How to Add Paragraph and Character Formatting | Word API for .NET Standard 2.0.

How to Add Paragraph and Character Formatting | Word API for .NET Standard 2.0.

Posted on 10/17/2018 3:04:55 PM

In this video, we’ll walk through adding a paragraph of text using GcWord. We’ll also add character formatting to different parts of the paragraph.

Make sure you have necessary namespaces included in your project.

In this example, we’ll use a combination of a set of random words from the util-dot-cs file.

First, copy a paragraph of text.

Create a GcWordDocument object.
Add the paragraph to the first section range of the Document's body.

The primary way to manipulate objects in GcWord is using ranges. Get the range on the paragraph that we've just added.

A Run is a contiguous fragment of a document with uniform formatting. In our case, we have only one run so far, so get that run.

Set the size of the font on the whole run.

Text represents a contiguous fragment of text. It also belongs to a Run,
and cannot span multiple runs, although a run can contain several Texts. Get the text object.

Split the text into two halves. Here, the split method returns the 2nd part.

At this point, our run contains two Texts, or two halves of the original text. We’ll now split the run into two corresponding runs so that we can apply different formatting to the two texts.


The 'text' was split into two halves, but the first half can still be accessed via the 'text' variable. A text's containing run can always be accessed via ParentRun.

We set the font of the first half to italic and the font of the second half to Red forecolor.


Save the Word file.

Run the project and the Word file is generated in your project.

Open the Word file.

The first half of paragraph is italic, while second half is red in forecolor.

MESCIUS Product Channels Select MESCIUS Product Channel

Related Videos

How to Programmatically Add Graphical Signatures to PDF Files Using JavaScript

11/17/2022 3:28:17 PM

Learn how to use GrapeCity Documents JavaScript PDF Viewer to add graphical signatures to your documents. This tutorial will show how to programmatically add PDF signatures to your web applications. ...

New Annotation and Form Designer Tools

11/17/2022 4:51:24 PM

In this video, GcPdfViewer introduces new annotations and form editor tools to work with PDF documents....

How to Use GcWord Report Templates to Automate Document Creation

11/17/2022 5:02:34 PM

In this video, we will present a step-by-step guide to binding report templates created in Microsoft Word with data to generate reports using the GcWord Report Templates feature....

How to Convert HTML to a PDF | GrapeCity Documents for PDF

11/21/2022 8:08:06 PM

GcHTML is a package available with GcPdf and GcImaging products. This allows the conversion of HTML content to PDFs and Images. In this video, we’ll convert an HTML file to PDF using GcPdf....

How to Export a Spreadsheet to a PDF | Documents for Excel, .NET Edition

11/22/2022 4:23:51 PM

GrapeCity Documents for Excel, .NET Edition, is a fast, efficient spreadsheet API that enables you to generate, load, modify, and save spreadsheets in your .NET Standard 2.0 app. With GcExcel, you can...

How to Add a Custom Theme to Your .NET Spreadsheet | Documents for Excel, .NET Edition

11/22/2022 4:24:09 PM

GrapeCity Documents for Excel, .NET Edition, is a fast, efficient spreadsheet API that enables you to generate, load, modify, and save spreadsheets in your .NET Standard 2.0 app. With GcExcel, you can...

How to Add Comments to a .NET Spreadsheet | Documents for Excel, .NET Edition

11/22/2022 5:37:58 PM

GrapeCity Documents for Excel, .NET Edition is a fast, efficient spreadsheet API that enables you to generate, load, modify, and save spreadsheets in your .NET Standard 2.0 app. With GcExcel, you can ...

How to Add Sparklines to a .NET Spreadsheet | Documents for Excel, .NET Edition

11/22/2022 5:38:11 PM

GrapeCity Documents for Excel, .NET Edition, is a fast, efficient spreadsheet API that enables you to generate, load, modify, and save spreadsheets. In this video, we’ll add sparklines to a set of da...

How to Add a Table to a Java Spreadsheet | GcExcel Java

11/22/2022 5:38:27 PM

GrapeCity Documents for Excel, Java Edition (GcExcel Java) is a high-speed, feature-rich Excel document API based on VSTO. We released the GcExcel for .NET Version in April, and with this launch it's ...

How to Add a Chart to your Spreadsheet | GcExcel Java

11/22/2022 5:38:40 PM

GrapeCity Documents for Excel, Java Edition (GcExcel Java) is a high-speed, feature-rich Excel document API based on VSTO. We released the GcExcel for .NET Version in April, and with this launch it's ...

How to Add a Pivot Table to your Spreadsheet | GcExcel Java

11/22/2022 5:39:22 PM

GrapeCity Documents for Excel, Java Edition (GcExcel Java) is a high-speed, feature-rich Excel document API based on VSTO. We released the GcExcel for .NET Version in April, and with this launch, it's...

How to Add Sparklines to a Spreadsheet | GcExcel Java

11/22/2022 5:39:35 PM

GrapeCity Documents for Excel, Java Edition (GcExcel Java) is a high-speed, feature-rich Excel document API based on VSTO. We released the GcExcel for .NET Version in April, and with this launch it's ...

How to Auto Filter Data in a Java Spreadsheet Application

11/22/2022 5:39:47 PM

GrapeCity Documents for Excel, Java Edition (GcExcel Java) is a high-speed, feature-rich Excel document API based on VSTO. This video is a step-by-step tutorial on how to automatically filter data in ...

How to Programmatically Convert Word .DOCX to PDF Using .NET C#

11/22/2022 5:58:48 PM

This tutorial will show how to programmatically convert Word .DOCX to PDF in a desktop application. Using a powerful Microsot Word .NET API library from GrapeCity Documents, you will be able to conver...

Add Slicer

12/1/2022 7:45:36 PM

Originally Published: 12-06-2018...

How to generate word docs in code

12/1/2022 7:47:11 PM

Originally Published: 12-04-2018...

Add Date Time Fields

12/1/2022 7:52:16 PM

Originally Published: 10-23-2018...

Load, Modify, and Add an Image

12/1/2022 7:54:53 PM

Originally Published: 10-23-2018...

GcExcel, Java Video Proof

12/1/2022 7:56:26 PM

Originally Published: 10-03-2018...

Conditional Formatting

12/8/2022 9:33:31 PM

Originally Published: 12-04-2018...

How to Add GrapeCity Documents for Excel, an Excel XLSX API Library, to Your Java App

3/9/2023 6:11:02 PM

In this tutorial, we will show you how to add GrapeCity Documents for Excel (GcExcel), a powerful Excel XLSX API library, to your Java application. Using IntelliJ, GcExcel Java Edition can be used in ...

How to Programmatically Convert HTML to PDF in .NET Core C#

3/10/2023 7:35:01 PM

In this tutorial, learn how to programmatically convert HTML documents to PDF format in your .NET Core C# applications. View the demos: https://www.grapecity.com/documents-api-pdf/demos/html Follow ...

How to Render HTML to PNG, SVG, JPEG, GIF in .NET 6 C# Apps

3/10/2023 9:18:16 PM

Learn how to render HTML in image types using this tutorial. We will show how to display HTML in PNG, SVG, JPEG, GIF. Follow along with the blog: https://developer.mescius.com/blogs/how-to-render-htm...

How to Enable PDF Collaboration Features Using a JavaScript Viewer Component

6/21/2023 1:44:37 PM

Learn how to enable PDF collaboration features using our JavaScript viewer Component, GcPDFViewer. This tutorial will show how to implement these features in your web application. Read more in this b...

JavaScript Image Editing Tutorial: Drawing and Painting on JPEG and PNG Images

10/16/2023 2:00:39 PM

Learn how to draw and paint on JPEG and PNG files using JavaScript in this web application image editing tutorial. Document Solutions Image Viewer (DsImageViewer), formerly GrapeCity Documents Image V...

How to Build a Simple Balance Sheet using C# .NET Excel APIs

12/18/2023 5:37:46 PM

Learn how to build a simple balance sheet application using a C# .NET Excel API library. Add Excel-like features to your desktop application using Document Solutions for Excel, .NET. Learn more abou...

How to Programmatically Convert Word DOCX to PDF Using C#

8/22/2024 4:12:00 PM

This tutorial will show how to programmatically convert Word .DOCX to PDF in a desktop application. Using a powerful Microsoft Word C# .NET API library from Document Solutions, you will be able to con...