How to create a blank Word DOCX document in C# .NET Framework

Cloudmersive
1 min readFeb 3, 2020

--

Today’s tutorial will show you how to create DOCX files from within an app. We are going to make things as simple as possible, so you should be all set to go in just a matter of minutes. Let’s begin.

First off, run this command in your Package Manager console to install our API client.

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 2.2.0

Now simply call EditDocumentDocxCreateBlankDocument, as you see here:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class EditDocumentDocxCreateBlankDocumentExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new EditDocumentApi();var input = new CreateBlankDocxRequest(); // CreateBlankDocxRequest | Document input requesttry{// Create a blank Word DOCX documentCreateBlankDocxResponse result = apiInstance.EditDocumentDocxCreateBlankDocument(input);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditDocumentApi.EditDocumentDocxCreateBlankDocument: " + e.Message );}}}}

And voila! Our blank document is ready. From here, we can use some other functions to fill it with content, such as EditDocumentDocxInsertImage or EditDocumentDocxInsertParagraph.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet