Presentation with Image

This guide will demonstrate the process of creating a presentation file with an image using UniOffice.

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 presentation/image folder in the unioffice-examples directory.

cd unioffice-examples/presentation/image/

How it works

The import section in lines 4-12, imports UniOffice packages and other necessary Go libraries. Then the init function in lines 14-21, sets the metered license key.

The main function in lines 23-60, contains the code that generates the presentation document with an image. Lines 21-31, create new presentation.Presentation and load two images from file. Then in lines 33-41, the images are added to the presentation using the Presentation.AddImage method. In line 45, a new slide is created using ppt.AddSlide(). Then the images and other properties are added to the slide in lines 47-54.

The presentation is validated in line 56. Finally, it is written to a file using ppt.SaveToFile("image.pptx") in line 59.

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.