Your Word document may have lot of flat text, but you may need to add more advanced features. In a .NET application, you can to add these features to Word documents in UWP apps using the rich API of C1Word library. In this blog we'll look at:

  • Creating Word documents in different paper sizes

  • Add Table of Contents

  • Flow text in columns and pages

  • Adding quotations etc.


Let's see how to code these advanced features using C1Word (Beta) library.

Download the Samples (UWP) | Download C1Studio


All of the examples below can be accessed in the Samples link.

Add text from a txt file in Word Document


If you have some text in a txt file and need to add it to Word document, you can easily use C1Word (beta) Library for this. In this example, we'll look at adding author names and their quotes to a document.

  1. Read the txt file in a stream

  2. Traverse through the author names and quotes and add them to a list.

  3. Traverse through this list and keep adding the Author name and quotes using C1Word.AddParagraph method with some formatting.


In the end, here is how the Word document looks:

Quotes


Adding Table of Contents to Word Document


Often in long documents, you might find it tough to locate certain portions of your document. Here, Table of Contents can help you jump to specific locations in the documents.

Using C1Word (UWP), you can programmatically add headers to a RTFTable object of C1Word. Once you get all the data of the document in a list, you can add bookmark information from the list object to the RTFTable object. Below is the kind of Table of Contents you can add to your document using C1Word.

TOC

Creating Document with Different Paper Sizes


Documents with different paper sizes often help you to control where the page is located or for any misaligned prints. Sometimes you need to fit an A3 page in middle of A4 size page documents to fit some drawing in your documents.

C1Word for UWP comes with the PaperKind enum (member of C1.Xaml.Word.PaperKind) that includes 110+ different paper sizes.

  1. Traverse through the list of PaperKind enum

  2. Create a RTFSection object of C1Word

  3. Send the particular PaperKind object to the particular section

  4. Add this section to the C1Word document object.


Here's the kind of document that is possible to create using C1Word:

PaperKind

Add Text in Columnar Layout


Text in two columns is often easier to read, since you don't have to move your eyes across the width of the page. Word documents in columnar layout are often needed when you are writing a newspaper, magazine or a book-like document.

Using C1Word library for UWP, you can add text in columnar format programmatically. Adding an RTFColumn to C1Word.MainSection.Columns collection divides the document into columns:

TextFlow in Columns

 

Please note that all documents in the snapshots above have been created using C1Word and opened in Microsoft Word © 2007.

Download the Samples (UWP) | Download C1Studio


What do you think about the advanced features of C1Word for UWP? Please leave a comment below. Thanks!