Presentation with Custom Slide Sizes

In this guide, the process of creating slides with custom size using UniOffice will be explained step by step.

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

To get the example navigate to the path presentation/slide-size folder in the unioffice-examples directory.

cd unioffice-examples/presentation/slide-size/

How it works

The import section imports the necessary Go libraries and UniOffice packages. The init function which is defined in lines 12-19, sets the license key before running the main function.

The main function is defined in lines 21-58. A new presentation is created in line 25 using ppt := presentation.New(). Then the for loop in lines 28-47, creates five slides using the AddSlide method of the presentation.Presentation object. The text boxes and related properties are then set in the lines 31-46.

In line 52, the presentation.SlideSize is obtained by calling the SlideSize method. Then the sizes are set using slideSize.SetSize(presentation.SlideScreenSize16x9) in line 53.

Finally, the presentation is validated and written to a file in lines 55-58 using:

if err := ppt.Validate(); err != nil {

Run the code

Run this command to generate the presentation file.

go run main.go

Sample output

sample image presentation

Got any Questions?

We're here to help you.