How to get styles from a Word DOCX document in C# .NET Framework

Cloudmersive
1 min readFeb 21, 2020

--

For today’s quick lesson, we will be demonstrating how to retrieve style information from a Word document in a matter of minutes.

Installing our API client should be the first order of business: run this command in your Package Manager console, and NuGet will take care of the rest.

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

Now simply call ConvertDocumentPptxToPdf.

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 EditDocumentDocxGetStylesExample{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 reqConfig = new GetDocxStylesRequest(); // GetDocxStylesRequest | Document input requesttry{// Get styles from a Word DOCX documentGetDocxStylesResponse result = apiInstance.EditDocumentDocxGetStyles(reqConfig);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditDocumentApi.EditDocumentDocxGetStyles: " + e.Message );}}}}

Done! All of the style information from our document will now be presented like this:

{
"Successful": true,
"Styles": [
{
"StyleID": "string",
"Path": "string",
"Bold": true,
"Italic": true,
"Underline": true,
"FontSize": "string",
"FontFamily": "string"
}
]
}

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet