MS Word provides a range of exciting features to create rich text documents. You can enrich your DOCX documents with text formatting, tables, graphics, images, WordArt, and so on. In certain cases, you may need to import a PNG image to the DOCX document programmatically. Or you may get a batch of PNG images that you need to convert into a DOCX file. To achieve that, this article shows how to convert PNG images to DOCX in C# .NET
C# PNG to DOCX Converter - Free Download
To convert PNG images to DOCX, we will use Aspose.Words for .NET. It is an amazing API which is primarily developed to create and manipulate Word documents. In addition, it provides a high-speed and high-fidelity converter to convert document and images files. You can download the API’s DLL or install it from NuGet using the package manager console.
PM> Install-Package Aspose.Words
Steps to Convert PNG to DOCX in C#
Aspose.Words for .NET hides the complex conversion operations and allows you convert any document or image file within a few steps. The following are the steps to convert a PNG to DOCX in C# using Aspose.Words for .NET.
- Install Aspose.Words for .NET in your application.
- Create a new DOCX document.
- Insert PNG image into the document using PNG file’s path.
- Save DOCX file to your desired location.
Convert PNG to DOCX in C#
Let’s have a look at how to transform the above-mentioned steps for PNG to DOCX conversion into the C# code. The following are the steps to convert a PNG to DOCX in C#.
- Create an instance of Document class.
- Create an instance of DocumentBuilder class and initialize it with Document object.
- Insert PNG image into the document by its path using DocumentBuilder.InsertImage(string) method.
- Save the output DOCX document using Document.Save(string) method.
The following code sample shows how to convert a PNG to DOCX in C#.
C# PNG to DOCX Converter - Get a Free License
You can use Aspose.Words for .NET without evaluation limitations using a temporary license.
In this article, you have learned how to convert a PNG to DOCX in C#. You can simply install Aspose.Words in your application and convert single or batch of PNG images to a DOCX in C#. Furthermore, you can explore other features offered by the API using the documentation. Also, you can feel free to ask your questions via our forum.