How to set the footer in a Word DOCX document in Java

What’s the easiest way to set up DOCX footers in Java? Let an API do the work for you! And that’s just what I’m about to show you how to do.

Let’s roll on out of the gate with our library installation. This involves Jitpack, so we just need to add these references to pom.XML.

Our repository reference:


And our dependency reference:


Next in line, we call editDocumentDocxSetFooter:

// Import classes://import com.cloudmersive.client.invoker.ApiClient;//import com.cloudmersive.client.invoker.ApiException;//import com.cloudmersive.client.invoker.Configuration;//import com.cloudmersive.client.invoker.auth.*;//import com.cloudmersive.client.EditDocumentApi;ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");Apikey.setApiKey("YOUR API KEY");// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.setApiKeyPrefix("Token");EditDocumentApi apiInstance = new EditDocumentApi();DocxSetFooterRequest reqConfig = new DocxSetFooterRequest(); // DocxSetFooterRequest | Document input requesttry {DocxSetFooterResponse result = apiInstance.editDocumentDocxSetFooter(reqConfig);System.out.println(result);} catch (ApiException e) {System.err.println("Exception when calling EditDocumentApi#editDocumentDocxSetFooter");e.printStackTrace();}

And here is how to format your footer input:

"InputFileBytes": "string",
"InputFileUrl": "string",
"FooterToApply": {
"Path": "string",
"Paragraphs": [
"ParagraphIndex": 0,
"Path": "string",
"ContentRuns": [
"RunIndex": 0,
"Path": "string",
"TextItems": [
"TextIndex": 0,
"Path": "string",
"TextContent": "string"
"Bold": true,
"Italic": true,
"Underline": "string",
"FontFamily": "string",
"FontSize": "string"
"StyleID": "string"
"SectionsWithFooter": [
"StartingPageNumbers": [
"Path": "string"

And that’s all there is to it!

Image for post

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store