- 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.
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.
- Read the txt file in a stream
- Traverse through the author names and quotes and add them to a list.
- 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:
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.
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.
- Traverse through the list of PaperKind enum
- Create a RTFSection object of C1Word
- Send the particular PaperKind object to the particular section
- Add this section to the C1Word document object.
Here's the kind of document that is possible to create using C1Word:
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:
Please note that all documents in the snapshots above have been created using C1Word and opened in Microsoft Word © 2007.
What do you think about the advanced features of C1Word for UWP? Please leave a comment below. Thanks!