Guide for C#
Core Document Formats
Additional Features

C# Word - Word Drawing in C#.NET

How to Draw Text, Line & Image on Word Using C# Code in .NET

Visual C#
Home > .NET Imaging SDK > C# > Word Drawing
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

This Visual C# Word document processor control, which is a composing library of RasterEdge DocImage SDK for .NET, is designed to help you add flexible imaging functions in your C# program. With this .NET Word processing add-on, developers can easily draw a line or a picture on your MS Word document, or write text on the page using C# code. In addition, all those texts & graphics drawn on the Word doc can be processed as independent image objects.
Related .net document control helps:
asp.net mvc pdf editor using c#: ASP.NET MVC PDF Viewer & Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
c# asp.net powerpoint viewer: ASP.NET PowerPoint Document Viewer Control (MVC & WebForms): view ppt, pptx files online in C# using ASP.NET
asp.net edit pdf page using c#: ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
c# asp.net tiff viewer: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control
asp.net edit pdf text using c#: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
c# asp.net text file viewer: ASP.NET Text file viewer in MVC, WebForms: Open, view, annotate, convert txt files in C# ASP.NET
asp.net document viewer open source: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
  • Compatible with Microsoft Visual Studio 2005, VS 2008 and 2010 versions
  • Easy to write any text into a Microsoft Office Word document with C#
  • Using C# codes to add line in any style or size into a defined area on a MS Word page
  • Draw, print various images / graphics on Word such as rectangle, ellipse, polygon, etc
  • Simple C# programming to adjust image color, size and other settings
  • Control the accurate picture location on Word page by specifying coordinates in C# codes
From this Word document drawing tutorial page, you can find the following information:
  • Text drawing on Word document using Visual C# code
  • Graphics drawing on Word page using Visual C# code
Besides this C# Word drawing guide, RasterEdge also provides other tutorials for developers to refer to, such as how to split a Word document using C# coding. If you want to create a Word document from scratch, here is Visual C# Word creating user manual. If you are looking for tutorial to print an MS Word file, we provide a C# guide for Word printing in Microsoft Visual Studio 2005.
How to Write & Draw Text on Word Document in C# Codes
From this section, you will find the Visual C# sample codes for text writing on an MS Word page. Using the C# codes in the example below, you can easily write text on the MS Office Word page in your C# image processing application. More samples are provided to help you adjust the text properties.
Visual C#.NET developers will be able to control various text properties by setting text content, font size, font style, color, location, etc. You only need to load the MS Word document from your local directory, and insert the text on the page. After that you can copy the sample codes below to adjust text properties.
The sample codes below will show you how to add the text "rasteredge.com" in "Arial" font with a red color, sized 16, using a "regular" font style. And this text will be printed on a Word document named "Sample.docx" which is stored in your local disk C.
public static string FolderName = "c:/";

private void button1_Click(object sender, EventArgs e)
{

RasterEdgeImaging Rectangle = new RasterEdgeImaging();

{
string fileName = FolderName + "Sample.docx";

REDocument doc = REFile.OpenDocumentFile(fileName, new DOCXDecoder());//use DOCXDecoder open a docx file
BasePage aPage = doc.GetPage(0);//get page from REDocument

REImage img = (REImage)aPage.ToImage();//translate page to image
Graphic Text = Graphics.FromImage(LoadImage);
Font DrawFont = new Font("Arial", 16, FontStyle.Regular);
SolidBrush DrawBrush = new SolidBrush(Color.Red);
PointF DrawPoint = new PointF(10.0F, 30.0F);
}
Text.TextDrawing = ("rasteredge.com", DrawFont, DrawBrush, DrawPoint);

Text.Save();
REFile.SaveDocumentFile(doc, fileName, new DOCXEncoder());
}
How to Draw Pictures & Graphics on Word Page in C# Codes
This RasterEdge Word processing add-on library can also help you add image drawing feature in your MS Word editing application. A variety of image types are supported for drawing & printing in Word document, such as ellipse, line, polygon, rectangle, and line, just to name a few.
As for the embedded images or graphics, users can easily control many of their properties such as image color, picture size, location of the graphics and more. All the customization can be done with simple Visual C# programming. Please check out the codings displayed in the code tab below.
The following C# code will guide you to draw a customized rectangle graphics on a Word document "Sample.docx" in your disk C. This rectangle image will be printed with the color red on the Word page according to the coordinates specified below. At last, the newly modified Word doc with inserted image will be saved to your disk with a defined file name.
public static string FolderName = "c:/";
private void button1_Click(object sender, EventArgs e)
{

RasterEdgeImaging Rectangle = new RasterEdgeImaging();

{
string fileName = FolderName + "Sample.docx";

REDocument doc = REFile.OpenDocumentFile(fileName, new DOCXDecoder());//use DOCXDecoder open a docx file
BasePage aPage = doc.GetPage(0);//get page from REDocument

REImage img = (REImage)aPage.ToImage();//translate page to image
Graphic Rectangle = Graphics.FromImage(img);
Pen myPen = new Pen(System.Drawing.Color.Red, 5);
Rectangle myRectangle = new Rectangle(20, 20, 250, 200);
}
Rectangle.RectangleDrawing = (mypen, myrectangle);
Rectangle.Save();
REFile.SaveDocumentFile(doc, fileName, new DOCXEncoder());
}
C# Imaging - Process Word Document Using C#.NET


Recommend this to Google+


RasterEdge.com is professional provider of ASP.NET MVC Document Viewer, ASP.NET PDF Viewer, MVC PDF Viewer document, content and imaging solutions, available for ASP.NET AJAX, Silverlight, Windows Forms as well as WPF. We are dedicated to provide powerful & profession imaging controls, PDF document, image to pdf files and components for capturing, viewing, processing, converting, compressing and stroing images, documents and more.

©2000-2017 Raster Edge.com