Split Word Documents in Go (Golang)

Split Word Documents in Go (Golang)

Words Cloud Go SDK provides an easy to use API to split DOCX, RTF, ODT and other file formats.
Cloud API has many split page features, such as:

  • Split pages no matter the length or file size.
  • Split page range.
  • Save as PDF, JPG, HTML, etc.


Use Go to split a Word document into multiple smaller files, or to extract pages to a new file.

Tip: Merging different Word documents is also possible.

Why split a Word document using Go?

While working with your documents, you may come across scenarios where you want to split large documents into smaller ones.
When scanning books, images or articles, you need to do it fast and all together. But in the end, you may want to separate pages of a Word document or any other document.
By splitting a document, you don’t need to send or print information you don’t want to.

What does split API for Go do?

  • Multi-page Word documents are divided into separate Word documents.
  • Split operation divides a multi-page Word document by page number, odd/even pages and by page range (entering the page range can be divided according to the page number of documents).
  • Split one big file into many smaller, one-page files. You can split them into multiple files, in various page ranges.
  • Keep style and layout of the source document.

Where and how?

Luckily for you, Words Cloud API has the answer.
The ability to split documents is one of four main feature areas of Words Cloud. It provides the simplest API to split a Word document within MS Word documents or other file formats.
Using an API client is the quickest way for a Go developer to speed up the development. API takes care of low-level details to make requests and handle responses. And this lets you focus on writing code specific to your particular project.

Getting Started

How to Split a DOCX document in Go

  1. Install the latest version of Go library.
  2. Go to the Aspose Cloud Dashboard.
  3. Create a new Account to access all applications and services or Sign In to your account.
  4. Click on Applications in the left menu to get Client Id and Client Secret.
  5. Check Developer Guide to split a DOCX file in Go.
  6. Check API Reference page for the description of APIs parameters.

Split a Word document in Go
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)

// Split all pages and save to PDF
wordsApi.SplitDocument(ctx, "sample.docx", "pdf", nil)

// Split page range 2-5 and save to JPEG
options := map[string]interface{}{ "from": 2, "to": 5 }
wordsApi.SplitDocument(ctx, "sample.docx", "jpeg", options)

// Split all pages, save to HTML and zip output files
options2 := map[string]interface{}{ "zipOutput": true }
wordsApi.SplitDocument(ctx, "sample.docx", "html", options2)
	"AppKey": "##################",
	"AppSid": "####-####-####-####-####"


Support and Learning Resources