How to Convert a Legacy PowerPoint File (PPT) to a Modern PowerPoint File (PPTX) using Go

Cloudmersive
2 min readNov 4, 2022

--

Ever since 2007, PPTX has been the default file format for all presentations created within the PowerPoint application; before that, the default file extension was PPT. As is often the case in a world of constantly evolving technologies, the relevance of those old files’ contents doesn’t die quite as quickly as the file format itself does, which leaves us with a tricky (and often frustrating) problem: how can we modernize our old files at scale while retaining the quality and aesthetic of the original documents?

Our PPT (97–03) to PPTX API represents a scalable, easy-to-use solution for the PowerPoint modernization problem. This API will quickly & programmatically convert your PPT files into PPTX files; simple as that. To use this API, you’ll just need to get a free-tier Cloudmersive API key (you can get one by registering a free account on our website) and follow brief instructions below to structure your API call using ready-to-run code examples in Go (for alternative code examples in C#, Java, Python & more, visit our API console page).

To call the API, all we need to do is copy & paste the below examples into our file. After that, include your PPT file path and API key in their respective fields:

package mainimport (
"fmt"
"bytes"
"mime/multipart"
"os"
"path/filepath"
"io"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/convert/ppt/to/pptx"
method := "POST"
payload := &bytes.Buffer{}
writer := multipart.NewWriter(payload)
file, errFile1 := os.Open("/path/to/file")
defer file.Close()
part1,
errFile1 := writer.CreateFormFile("inputFile",filepath.Base("/path/to/file"))
_, errFile1 = io.Copy(part1, file)
if errFile1 != nil {
fmt.Println(errFile1)
return
}
err := writer.Close()
if err != nil {
fmt.Println(err)
return
}
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "multipart/form-data")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
req.Header.Set("Content-Type", writer.FormDataContentType())
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

Just like that, you’re finished. No more code needed!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet