Merge MS Word Documents using C# ASP.NET

Merge Word Documents ASP.NET

Merging multiple MS Word documents could be useful in various scenarios. For example, it can be used in keeping a similar type of documents into a single file, combining multiple documents before sharing, and so on. Various online tools are available that allow you to merge MS Word documents quite easily, however, what if you want to add this feature within your own application? To make you achieve this, I’ll show you how to merge MS Word (DOC/DOCX) documents using C# within your ASP.NET web applications. This Word Document Merger application will have the following features:

  • Merge MS Word Documents into a Single Document
  • Download Merged Word Documents as DOCX Format
  • Download Merged Word Documents as PDF Format

.NET API to Merge MS Word Documents in ASP.NET

Aspose.Words for .NET is a feature-rich word processing API that lets you process MS Word documents with ease. It also allows you to merge multiple Word documents into a single document within ASP.NET or any .NET/.NET Core application. Aspose.Words for .NET can be installed using NuGet as well as downloaded as a DLL file.

PM> install-package Aspose.Words

Merge MS Word Documents in ASP.NET

The following are the steps to create an ASP.NET application that will let you merge two or more Word (DOC/DOCX) documents without using MS Office/Word.

  • Create an ASP.NET Core Web Application in Visual Studio.
Create ASP.NET Core Web Application
  • Choose the Web Application (Model-View-Controller) from the template list.
Select MVC Application
  • Install the Aspose.Words for .NET from NuGet Package Manager or Package Manager Console.
.NET API for Word Comparison
  • Insert the following script in your index.cshtml file.
  • Insert the following code in your HomeController.cs class.
  • Include the following JS and CSS files of drag and drop plugin within the head tag of _layout.cshtml file.
  • Build the application and run it in your browser.
ASP.NET Word Document Merger

ASP.NET Word Document Merger App – Demo

The following is the demonstration of merging MS Word documents using our ASP.NET Word Document Merger app.

Merge multiple DOCX files in ASP.NET

Download

Download the source code of ASP.NET Word Document Merger application from here.

Try Aspose.Words for .NET for Free

Get your temporary license (a complete license for 30 days) to try Aspose.Words for .NET for free.

Related Article

Posted in Aspose.Words Product Family | Tagged , , | Leave a comment

Convert PUB to PDF file Programmatically using C++

PUB files are usually used to create or edit the publications. Pamphlets, brochures, visiting cards, and many other types of files are created in Microsoft Publisher application thus saved as the file extension .pub. However, because of the popularity and support of PDF format, you may need to convert PUB to PDF. For such scenarios, Aspose.PUB for C++ API is the answer to your requirements.

Aspose.PUB for C++

Looking at the background information about the API, previously only Aspose.PUB for .NET API was available so one could use that with C# or VB.NET programming language. However, the increasing and repeating requests for supporting the C++ platform resulted in the conception of Aspose.PUB for C++ API. Now you can edit, manipulate, and convert PUB files in your C++ applications.

Installation

The API is available at the Downloads section as well as on the NuGet gallery. Where you can simply run the following command or install using NuGet Manager for Solution, in Visual Studio IDE.

PM> Install-Package Aspose.PUB.Cpp

Free Temporary License for Evaluation of Aspose.PUB for C++

Like other APIs offered by Aspose, we also offer a free trial license for 30 days for Aspose.PUB for C++ API as well. This allows you to test the API in its full capacity. However, the trial period can be extended a few times, upon request, if your POC, Feasibility, or any other organizational procedure needs some time. You can learn detailed information on Temporary License page if you want to test before paying for the API.

Convert PUB to PDF in C++

Since you have installed and set up the API by now. We are good to convert a PUB file to PDF. Let us work with a sample Microsoft Publisher file to PDF with below steps:

  1. Load input PUB file
  2. Convert PUB to PDF with ConvertToPdf method
  3. Save the output PDF file

Following C++ code is based on these steps which show how to convert PUB to PDF in your C++ applications.

Below screenshot shows the output PDF file generated with the C++ code snippet we have just tested:

Convert PUB to PDF

It is important to note here that Aspose.PUB for C++ API supports input PUB file with several pages to be converted to a PDF file containing many pages. Moreover, we will keep enhancing the PUB to PDF rendering with upcoming releases.

Conclusion

Publisher files are frequently used in modern times and the feature of PUB to PDF file format is very important. That is why it is one of the first features being included in the C++ version of the API. In case you need any assistance while installing or converting PUB files, get in touch with us via Free Support Forum.

See Also

Convert EPUB to PDF

Posted in Aspose.PUB Product Family | Tagged , , , , | Leave a comment

Compare Two Word Documents using C# in ASP.NET

Compare Word Documents in ASP.NET

We often need to compare two MS Word DOC/DOCX documents to check the similarities or differences. The comparison gives us an idea of what has been changed in the two versions of a single Word document. Various online document comparison applications are available that let you compare two Word documents. However, there could be the case when you need to integrate document comparison features within your web application. On the other hand, you may want to build your own online document comparison app. To deal with such cases, I’ll show you how to compare two Word documents using C# within ASP.NET web application. This application will have the following features.

  • Compare two Word (DOC/DOCX) documents
  • Download the comparison result in DOCX format
  • Download the comparison result in PDF format

.NET API to Compare Word Documents

To perform the comparison of the Word documents without MS Office, we’ll use Aspose.Words for .NET which is a powerful word processing API for ASP.NET or other .NET/.NET Core applications. You can download API or install it within your ASP.NET application using NuGet.

PM> Install-Package Aspose.Words

Compare Two Word Documents in C# ASP.NET

  • Create a new ASP.NET Core Web Application in Visual Studio 2017 or later.
Create ASP.NET Core Web Application
  • Choose the Web Application (Model-View-Controller) template.
Select MVC Application
  • Install the Aspose.Words for .NET package using NuGet Package Manager.
.NET API for Word Comparison
  • Copy and paste the following script in index.cshtml view.
  • Copy and paste the following method in HomeController.cs controller.
  • Insert the following CSS and JS files of drag and drop plugin in the head tag of _layout.cshtml view.
  • Build the application and run in the browser.

ASP.NET Word Document Comparison App – Demo

The following is the demonstration of how to compare two Word documents using our ASP.NET document comparison application.

Compare Word DOCX in ASP.NET

Download

You may download the complete source code of ASP.NET Word document comparison application from here.

About Aspose.Words for .NET

Try Aspose.Words for .NET for Free

Aspose offers a temporary license to try Aspose APIs for free. Get yours to evaluate Aspose.Words for .NET.

Related Article

Posted in Aspose.Words Product Family | Tagged , , | Leave a comment

Convert a Document using Aspose.Words

Aspose.Words

Converting documents from one format to another is one of the main features of Aspose.Words. Conversion in Aspose.Words consists of opening a document in one of the supported load formats and then saving it in another format.

You can convert a document from one of most popular formats to another. Aspose.Words supports almost all common conversion combinations, for example:

  • DOC, DOCX, RTF to PDF or XPS,
  • DOC or DOCX to JPEG, TIFF, PNG,
  • DOCX to Markdown or HTML,
  • PDF to DOC, DOCX, or other Word formats,
  • and others.

Please note that this is not a complete list of possible conversions. You can check out LoadFormat that specifies all load or import formats and SaveFormat that specifies all save or export formats supported by Aspose.Words.

How to Convert a Document

First, you need to load a document into Aspose.Words. Then you need to save this document in the required format. Follow these two simple steps and you will find out how easily Aspose.Words allows you to convert documents.

Note that you can specify additional options when saving a document to get the desired result. We will also discuss it below.

How to Load a Document

To load a document pass the file name or the stream into one of the Document constructors. The format of the loaded document is determined by its extension – this happens automatically.

The following example shows how to load a document from a file:

// Load the document from the absolute path on disk.
Document doc = new Document(dataDir + "TestDocument.docx");

How to Save a Document

To save your document, use one of the Save methods. Aspose.Words automatically determines the desired save format from the file extension. You can save a document both to a file or a stream. For example, you can save a DOCX document as a PDF file.

The following example shows how to save a document to a file:

// Save the document as a PDF file.
doc.Save(dataDir + "Document.pdf");

Specify Advanced Conversion Options

When converting a document, you can set some advanced properties. Aspose.Words provides you with the SaveOptions class, which allows you to control the process of saving your document in the required format more precisely. Each save format has a corresponding class that holds the save options for this save format. For example, there is HtmlSaveOptions for saving to HTML/MHTML/EPUB format, or PdfSaveOptions for saving to PDF. You can read more about advanced properties in the article ‘Specify Save Options’ in the Aspose.Words documentation.

The following example shows how to convert a document from DOCX to PDF and set Aspose.Words to embed full fonts in the output document:

// Load the document from the file.
Document doc = new Document(dataDir + "TestDocument.docx");

// Aspose.Words embeds full fonts by default when EmbedFullFonts is set to true.
// The property below can be changed each time a document is rendered.
PdfSaveOptions options = new PdfSaveOptions();
options.EmbedFullFonts = true;

// The output PDF will be embedded with all fonts found in the document.
doc.Save(dataDir + "TestDocument.EmbedFullFonts.pdf", options);

Variations of Conversions Supported by Aspose.Words

As mentioned above, Aspose.Words allows you to convert a document from one of most popular formats to another. This means that you can solve most of your conversion tasks using only Aspose.Words without installing special applications or tools. For example, you can easily and reliably convert a document from Microsoft Word formats such as DOC or DOCX to PDF or HTML, or from PDF or HTML to Markdown.

Study the ‘Converting a Document’ documentation section for more Aspose.Words conversion examples.

See Also

To understand this question in more detail, look at the following articles in the Aspose blog:

Posted in Aspose.Words Product Family | Tagged , , , | Leave a comment

Create Animated PNG Images using C# or VB.NET

Animated PNG (Portable Network Graphics) is an extension to PNG format to incorporate the animations. Just like animated GIFs, APNG format is used to present the animations. An edge of APNG over GIF is, it supports 24-bit transparency whereas GIF supports only 8-bit. Furthermore, APNG provides a smoother animation as compared to an animated GIF. In this article, I’ll show you how to create the animated PNG (APNG) images from an image or multi-page Tiff and export APNG to animated GIF programmatically using C# (or VB.NET).

.NET API for Animated PNG Images

Aspose offers its .NET Imaging API to create or manipulate popular image formats including animated PNG using C# or VB.NET. We’ll leverage the capabilities of Aspose.Imaging for .NET to create or export animated PNG images. You can either download the API’s DLL or install it within your .NET application using NuGet.

PM> Install-Package Aspose.Imaging

Create Animated PNG from an Image using C#

Aspose.Imaging for .NET lets you create an animated PNG from a single-page image such as PNG by setting the custom animation and frame duration. The following are the steps to perform this operation.

The following code sample shows how to create an animated PNG (APNG) from a PNG image using C#.

Source PNG

PNG to APNG in C#

Animated PNG

Create animated PNG

Create Animated PNG from Multi-Page Tiff using C#

You can also use a multi-page Tiff file to create the animated PNG by setting the desired frame time. The following are the steps to create animated PNG from a Tiff file.

The following code sample shows how to create animated PNG from a Tiff file using C#.

Source Tiff

You can download the source Tiff file from here.

Animated PNG

TIFF to Animated PNG

Export Animated PNG to Animated GIF using C#

You can also export an animated PNG image to an equivalent animated GIF. The following are the steps to export APNG to GIF.

The following code sample shows how to export animated PNG to GIF using C#.

Source Animated PNG

Animated PNG Image

Animated GIF

Animated PNG to GIF C#

Conclusion

In this article, you have learned how to create an animated PNG from different sources using C#. The step by step guide and code samples demonstrated how to create animated PNG from single-page PNG and multi-page Tiff as well as export animated PNG to an animated GIF using C#. You can learn more about manipulating APNG images using the documentation of the API.

See Also

Posted in Aspose.Imaging Product Family | Tagged , , , | Leave a comment

Convert AI to PNG, JPG, PSD and PDF file with C# .NET

Adobe Illustrator files are majorly used to represent visual information. Moreover, graphic designers transform their creative ideas into masterpieces using AI files. Sometimes you need to convert AI to raster images (PNG, JPG, etc) or PDF file. The most important and exciting factor of all these conversions is that you do not need to install or configure the Adobe Illustrator application because Aspose.PSD for .NET API is capable of converting AI files without any dependency on 3rd party applications. Let us move on to the following use cases in this blog post:

It is important to note here that we will be considering two different AI files as input for a few examples below. One of the input AI file has different paths weight and the other AI file contains complex contours. So let us check out the screenshots for the AI files we will be working with:

AI File with Different Path Weights

AI to PNG

AI File Containing Complex Contours

AI to JPG

Convert AI to PNG with C#

You can enhance your .NET applications to process AI files and convert it to a PNG image. PNG images are quite famous and are often the criteria for submitting images in online forms. So you can follow the below steps to convert AI to PNG files:

  1. Load source AI file
  2. Set properties of PngOptions class
  3. Save AI file as PNG image

Following code snippet is based on the above steps, which shows how to convert AI to PNG with C#:

Convert AI to JPG with C#

Converting AI files to JPG image is simple. You need to follow the steps below:

  1. Load input AI file with AiImage class
  2. Set ImageOptionsBase properties
  3. Save output JPG image

Following code snippet shows how to convert AI to JPG in C# applications:

Convert AI to PSD with C#

PSD files are photoshop documents that contain layered images. You can convert AI to PSD without using Adobe Photoshop or Adobe Illustrator. Follow the steps below in order to perform the conversion:

  1. Load AI input file
  2. Initialize object of PsdOptions class
  3. Save output PSD file as a result

Likewise, the code snippet below shows how to convert AI to PSD in C# .NET applications:

Convert AI to PDF with C#

PDF files format is famous because almost all platforms support .pdf file extension. Moreover, the PDF files are prone to changes and modifications unless permitted by the author of the document. Sometimes you might need to share content with partners or customers without allowing them for any modifications. Therefore, AI to PDF conversion is helpful in such scenarios. You need to follow the below steps to perform the conversion:

  1. Load source AI file
  2. Declare an instance of PdfOptions class
  3. Save output PDF file consequently

Following code snippet shows how to convert AI to PDF with C#:

Conclusion

In short, AI files can be rendered to different file formats with Aspose.PSD for .NET API. For example, we have explored how to convert AI to PNG, AI to JPG, AI to PSD as well as AI to PDF file formats. So you can visit the API documentation and API references to learn more about the API. Moreover, we appreciate your feedback or queries at Free Support Forum.

See Also

Add Fill Layer in PSD file

Posted in Aspose.PSD Product Family | Tagged , , , , , , , | Leave a comment

Draw Graphics and Create 2D Drawings using C# or VB.NET

Draw Graphics using C#

In my previous article, I have given you an overview of our .NET Graphics API – Aspose.Drawing for .NET. Along with that, we have seen how to create images from scratch or draw graphics on existing images using C#. In this article, we’ll go one step ahead and learn how to create 2D drawings by drawing various graphical objects within the .NET applications such as ASP.NET web application, Windows application, and etc.

The following are the vector graphics that we are going to draw within our drawings using .NET Graphics API.

Before we start, make sure you have installed Aspose.Drawing for .NET within your .NET application. You can read about the installation methods in this post.

Create a Drawing from Scratch using C#

First of all, let’s have a look at how to create an empty drawing and save it as a PNG image. The steps are as simple as pie.

You can save the drawing in other image formats as well. The following code sample shows how to create a drawing from scratch using C#.

Draw an Arc in Drawing using C#

Let’s check out how to draw an arc within the drawing. The following are the steps to perform this operation.

The following code sample shows how to draw an arc in the drawing using C#.

Draw an Arc

Draw a Bezier Spline in Drawing using C#

The following are the steps to draw a bezier spline within a drawing.

The following code sample creates a Bezier Spline using C#.

Draw Bezier Spline

Add a Cardinal Spline in Drawing using C#

Use the following steps to draw a cardinal spline using our .NET Graphics API.

The following C# code sample draws a cardinal spline using Aspose.Drawing for .NET.

Draw Cardinal Spline

Add a Closed Curve in Drawing using C#

You can also draw a closed curve in the same way you have drawn the other graphical objects. The following are the steps for this.

You can draw a closed curve using the following C# code sample.

Draw Closed Curve

Draw an Ellipse in a Drawing using C#

The following are the steps to draw an ellipse in a drawing using Aspose.Drawing for .NET.

The following code sample shows how to draw an ellipse using C#.

Draw Ellipse

Draw Lines in a Drawing using C#

Lines are one of the basic objects for creating the drawings. The following are the steps to draw the lines in a drawing using Aspose’ Graphics API.

The following code sample shows how to draw lines within a drawing using C#.

Draw Lines

Draw a Path in the Drawing using C#

The following are the steps to draw a path within a drawing using C#.

The following code sample shows how to draw a path within a drawing using C#.

Draw Path

Draw a Polygon in a Drawing using C#

The following are the steps to draw a polygon within a drawing using Aspose.Drawing for .NET.

This is how you can draw a polygon within a drawing using C#.

Draw Polygon

Draw a Rectangle within the Drawing using C#

Last but not the least, drawing a rectangle. The following are the steps to draw a rectangle.

The following C# code sample draws a rectangle within a drawing.

Draw Rectangle

Conclusion

In this article, we have seen how various graphical objects can be drawn within a drawing programmatically using C#. The step by step guide and code samples demonstrated how to draw lines, rectangles, polygons, arcs, bezier spline, cardinal spline, curves and ellipses within the drawings. You can learn more about our .NET Graphics API using the documentation.

See Also

Posted in Aspose.Drawing Product Family | Tagged , , , | Leave a comment

Load a PDF File to Further Modify and Convert It using C#

In many cases, while working with a PDF document, you need to change it: copy, paste, drag and drop specific PDF content such as text, images, tables, and diagrams. It’s fine to perform these options manually inside the same PDF file as long as you want to work with small parts of your document. But what if you want to perform the editing options in more complex scenarios such as creating a digital signature, merging multiple PDF documents, or reprocessing all the text in a PDF file?

Aspose.Words answers the question with a fast and accurate tool that allows you to load, edit, and convert PDF to any supported file formats such as DOCX, HTML, Markdown, and others. This article will guide you through the usage of these options both programmatically using C# and online.

Features of Loading a PDF Document using C#

Usually, PDFs are used only for viewing, but sometimes you may need to edit or add something new to the existing PDF document.

Aspose.Words provides additional options to work with PDF documents such as:

  • Convert PDF to multiple formats and extract data.
  • Print PDF documents with a variety of printing options.
  • Encrypt and decrypt PDF as well as modify passwords, and others.

In addition to loading a PDF document, you can create PDF documents programmatically in C# and manage the PDF content such as:

  • Add, update, delete text and images.
  • Insert text and image in headers and footers.
  • Manipulate, export, and import annotations.
  • Add, modify, and remove bookmarks.
  • Add tables, graph objects during PDF generation, and others.

Convert from PDF to the Desired Format using C#

One of the main features of Aspose.Words is the ability to easily and reliably convert documents from one file format to another. In Aspose.Words, converting a PDF document format to another format, such as DOCX, is a very simple process and can be accomplished with few lines of code. You can convert PDF to DOCX programmatically in C# by implementing the following conversion steps:

  1. Load a PDF document.
  2. Save the result to the target file format.
Note: You can apply some additional options when loading or saving a document.

Let’s describe the process of converting a PDF document into a DOCX file format in C# by going through the previous steps with all necessary programming details.

Load a PDF Document

Most tasks that you want to perform with Aspose.Words will require you to load a document as a first step of the conversion process. When you load a PDF document into Aspose.Words, it builds its DOM (Document Object Model), and all document elements and formatting are simply loaded into memory. Use one of the document constructors to either create a blank document or load your PDF document. You can create a blank document with any necessary content or load your document from a stream, as it’s explained in the ‘Creating or Loading a Document’ article.

The following example shows how to load a PDF document from a file in C#:

// Load your PDF document into a Document object using one of its constructors
// and the path to your file.
Document doc = new Document(@"C:\DocumentName.pdf");

Save a Document in Any Supported Format

Most tasks that you want to perform with Aspose.Words will require you to save a document as a final step. Aspose.Words supports many different save or export formats that are listed in the SaveFormat enumeration. Use one of the Save methods to save the result to a local file, for example, in the DOCX file format.

To achieve that programmatically in C#, invoke the Document.Save method on the Document object and specify the desired output format as DOCX by entering your file name with the “.docx” extension:

// Save your document as a DOCX file.
doc.Save(dataDir + "DocumentName.docx");

Congratulations, you have successfully managed to convert your PDF file to DOCX.

Apply Additional Options

You can apply different PDF save options or PDF load options, and here are a few examples, such as digital signatures, page range, and document open password. Let’s learn more about them.

Add and Verify Digital Signatures

Aspose.Words allows you to sign a PDF document using the DigitalSignatureDetails PDF save option property. You need to upload a digital certificate from disk or from a certificate store and pass it to a new instance of the X509Certificate2 class.

The following code example shows how to sign a PDF document in C#:

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

// Create a simple document from scratch.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Load the certificate from disk.
// The other constructor overloads can be used to load certificates from different locations.
X509Certificate2 cert = new X509Certificate2(dataDir + "signature.pfx", "signature");

// Pass the certificate and details to the save options class to sign with.
PdfSaveOptions options = new PdfSaveOptions();
options.DigitalSignatureDetails = new PdfDigitalSignatureDetails();
dataDir = dataDir + "Document.Signed_out.pdf";

// Save the document as PDF.
doc.Save(dataDir, options);

Set Page Range

To set the page range of loading your PDF document, you will need to use the PageIndex property to specify the index of the start page and the PageCount PDF load option property to set the total number of pages to load starting from the specified index:

var loadOptions = new PdfLoadOptions { PageIndex = 2, PageCount = 4 };
var doc = new Document("YourDocumentName.pdf", loadOptions);

Open Protected PDF with Password

You can open an encrypted PDF document by specifying the password value directly in the PDF load options:

var loadOptions = new PdfLoadOptions { Password = "123456" };
var doc = new Document("YourDocumentName.pdf", loadOptions);

PDF Online Converter

If you’re not a programmer, then it’s better to use the online PDF converter. As a first step, all you have to do to convert PDF online is to point your Web browser to the following page on the Aspose Website at the file converter tool.

Let’s guide you through the online conversion process step-by-step:

  1. Drag & drop or select a PDF file to upload by clicking on the button “Drop or Upload your files” as shown in the picture below.
  2. Select DOCX file format from the drop-down list, or choose a different file format.
  3. Click on the button “Convert” to convert your PDF file as shown in the picture below.Convert your PDF
  4. Click on the button “DOWNLOAD NOW” to download the conversion result as a DOCX file. Also, you can view the conversion result on Aspose File Viewer by clicking on the button “VIEW RESULTS”  as shown in the picture below.View results
  5. Congratulations, you have successfully managed to load, convert and save your PDF file to DOCX with our online file converter.

See Also

If you want to achieve the opposite direction and load a Word document to PDF then you can read the following article: Convert Word Document to PDF Programmatically in C# .NET – A Complete Guide.

Posted in Aspose.Words Product Family | Tagged , , | Leave a comment

.NET Graphics API – Create Images and Graphics from Scratch using C#

.NET Graphics API

You would have come across various drawing applications (i.e. MS Paint) that allow you to draw graphics and generate images. However, what if you want to create your own drawing utility or integrate drawing features within your web or desktop application? For such scenarios, Aspose offers its .NET Graphics API as Aspose.Drawing for .NET which is a lightweight solution for creating images and drawings identical to GDI+.

Without any dependencies of the native code and libraries, Aspose.Drawing for .NET lets you draw various graphical objects such as lines, arcs, rectangles, polygons, ellipses, etc. as well as use pens and brushes to create 2D graphics using C# or VB.NET. In this article, I’ll demonstrate how to create an image from scratch or draw graphics on an existing image using C# with our drawing API.

.NET Graphics API – Installation

Before we start, lets first have a look at the installation methods of Aspose.Drawing for .NET. You can either download the API’s DLL or install it using the NuGet within the Visual Studio.

PM> Install-Package Aspose.Drawing

Create an Image from Scratch using C#

In this section, I’ll show you how to use the API for creating an image from scratch. For the demonstration, I’ll add only a couple of graphical objects to the image, however, the same code can be extended for adding the other objects. The following are the steps to create an image using Aspose.Drawing for .NET.

The following code sample shows how to create an image from scratch using C#.

Output

create an image from scratch in C#

You can visit the following documentation article for the code samples of drawing other graphical objects:

Draw Graphics on Existing Images using C#

You may also load an existing image and draw the desired graphical objects on it. Loading and working with an existing image is as simple as creating a new one. The following are the steps to perform this operation.

  • Create an instance of Bitmap class and initialize it with the image’s path.
  • Draw desired graphics such as line, polygon, etc. in the same way you have done in the previous example.
  • Save the updated image using Bitmap.Save(string) method.

The following code sample shows how to draw graphics on an existing image using C#.

Output

draw graphics on image C#

Conclusion

In this article, I have shown you how to use the basic features of Aspose.Drawing for .NET and create images from scratch or add graphics on existing images using C#. In order to explore all the features of the API, you can consult the documentation and download the code samples.

For the upcoming posts and tutorials on Aspose.Drawing for .NET, stay tuned and keep visiting Aspose.Drawing Product Family section.

Posted in Aspose.Drawing Product Family | Tagged , , , | Leave a comment

Add or Remove Watermark in Word Document (DOCX/DOC) in C#

Watermarks are usually used to show ownership or classification of a document. In this article, we will learn to work with watermark in word documents using Aspose.Words for .NET API. Let us cover the following use cases related to watermark.

Add Text Watermark in Word Document with C#

You can add or insert text watermark in a word document, be it a DOC or DOCX file. Simply follow the steps below for adding text watermark:

  1. Load input DOC/DOCX file
  2. Set different TextWatermarkOptions including Font and Layout
  3. Set text of the watermark
  4. Save the output word file

Following code snippet shows how to add watermark in word document (DOC/DOCX) using C#:

The screenshot below is a sample output created by above C# code snippet:

Watermark in word

Add Image Watermark in Word Document with C#

You can also add an image as a watermark in a word document. The image can be added in addition to the text, as we have learned in the previous example. You can follow below steps to add image watermark in a word document:

  1. Load input word file
  2. Initialize ImageWatermarkOptions object
  3. Set image as watermark in the word document
  4. Save the output file

Following code snippet is based on these steps which show how to add image watermark in word documents using C#:

We have used Aspose logo image as sample image so you can observe the output in Print Preview of Microsoft Word application where an image is set as a watermark of the document. Following screenshot depicts the output word file:

image watermark in word file

Remove Watermark in Word Document using C#

You can easily remove or delete a watermark from word document using C#. Let us follow the steps below for removing a watermark from the word document.

  1. Load input word file
  2. Specify the type of watermark to remove
  3. Remove watermark
  4. Save the output word file

Following code snippet shows how to remove a watermark from word document with C#:

Conclusion

We have learned how to add or insert text watermark in word documents. Moreover, we have also explored how to add image watermark in word documents. You can use these features separately or maybe in combination as well, i.e Adding text and image watermark in word document at the same time. Furthermore, your .NET application can be efficient enough to remove or watermarks from word documents. We have created this article as a simple guide to work with watermarks in word. In case of any query or concerns, please contact us via Free Support Forum.

See Also

Create MS Word Editor in ASP.NET MVC

Posted in Aspose.Words Product Family | Tagged , , | Leave a comment