Line Spacing

This guide will show you how to work with line spacing in text.

Before you begin

You should get your API key from your UniCloud account.

If this is your first time using UniOffice SDK, follow this guide to set up a local development environment.

Clone the project repository

In your terminal, clone the examples repository. It contains the Go code we will be using for this guide.

git clone https://github.com/unidoc/unioffice-examples

To get the example navigate to the path document/line-spacing folder in the unioffice-examples directory.

cd unioffice-examples/document/line-spacing/

How it works

Lines 4-12 import the UniOffice packages and other required dependencies.

The init function in lines 14-21 authenticates your request with your UNIDOC_LICENSE_API_KEY.

In the main function in lines 23-47, a new document is generated, and a variable named lorem, which holds text, is defined. Next, a new paragraph is created, comprising a single run that inserts the content of the lorem variable twice. Subsequently, a blank line is inserted beneath this paragraph using the AddBreak() function.

Following this, the same operations are repeated, but this time specifying the line spacing using the SetLineSpacing() function.

Finally, the document is validated and saved.

Run the code

Run this command to create a new document with line spacing.

go run main.go

Sample output

Line Spacing example

Got any Questions?

We're here to help you.