This article guides how to remove borders in Word with NET REST API. You will learn to automatically remove paragraph border in Word with C# REST API using the .NET cloud SDK. We will learn the process to remove individual or all the borders from a paragraph.
Prerequisite
- Create an account and get API credentials
- Download Aspose.Words Cloud SDK for Dotnet to remove a border in a Word file
- Setup C# solution project with the above SDK for eliminating borders
Steps to Remove a Border in Word with C# Low Code API
- Initialize the WordsApi object by setting the cloned ID and secret to remove paragraph borders
- Create an object of the DeleteBordersOnlineRequest class for removing all borders
- Read the input Word file into the memory stream for deleting a border
- Set the destination file name, node path, and document binary stream in the request object
- Call the DeleteBordersOnline() method to remove the borders
- Save the output stream to a file from the API response object
The above steps summarize how to remove border in Word with C# Low Code API. Create an object of the WordsApi class, create a DeleteBordersOnlineRequest object, and set its properties. Invoke the DeleteBordersOnline() method to delete the border.
Code to Remove Paragraph Border in Word with C# REST API
using System.IO; | |
using Aspose.Words.Cloud.Sdk; | |
using Aspose.Words.Cloud.Sdk.Model.Requests; | |
namespace WordsSample.Words | |
{ | |
public class WordFileOperations | |
{ | |
public void DeleteBorder() | |
{ | |
var wordsApi = new WordsApi("Client ID", "Client Secret"); | |
var request = new DeleteBordersOnlineRequest(); | |
request.Document = File.OpenRead("Example.docx"); | |
string output = "output.docx"; | |
request.DestFileName = output; | |
request.NodePath = "sections/0/paragraphs/1"; | |
var task = wordsApi.DeleteBordersOnline(request); | |
task.Wait(); | |
var result = task.Result; | |
if (result.Document.TryGetValue(output, out var stream)) | |
{ | |
stream.Position = 0; | |
using (var fileStream = File.Create(output)) | |
{ | |
stream.Seek(0, SeekOrigin.Begin); | |
stream.CopyTo(fileStream); | |
} | |
} | |
} | |
} | |
} |
This sample code exhibits how to remove a border in Word with NET REST API. When we call the DeleteBordersOnline() we do not need to set the border type value. However, if you want to delete a particular border, use the DeleteBorderOnline() method and set the border type in the request object.
We have learned to remove borders from the paragraphs. To add a border to a paragraph, refer to the following article: Add a Border to a Word Document with NET REST API.