Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Sat Feb 18, 2012 5:16 pm


I have a word template where I want to add images at specific locations.
What's the best way to do it? Is it to insert dummy images in the template to replace or can I in a simple way say where to insert images?



Posts: 3
Joined: Sat Feb 18, 2012 3:51 pm

Mon Feb 20, 2012 4:17 am

Hi Magnus,

Thanks for evaluating spire.Doc and sorry for the late reply.

You can locate the image through the paragraph and the alignment. We attached you a demo illustrates how to do it. Please have a look.

If you still have questions,please don't hesitate to contact us.
Have a nice day.

e-iceblue support
You do not have the required permissions to view the files attached to this post.
User avatar

Posts: 154
Joined: Thu Oct 20, 2011 2:53 am

Mon May 14, 2012 3:38 pm

After deep investigation at last I got a solution for it,
It can work for others too,

For image moving just use it
//string sToPath = pMapPath + "pictures";
string sToPath = pMapPath + pToImageFolder;
DirectoryInfo toDirInfo = new DirectoryInfo(sToPath);
//move all files
foreach (FileInfo file in fromDirInfo.GetFiles()) {
file.MoveTo(Path.Combine(sToPath, file.Name));


and for image mappings and style mapping just use System.IO.File in asp.net

string sHtmlFileContents = File.ReadAllText(sHtmlFile);
sHtmlFileContents = sHtmlFileContents.Replace(imgFolder, "pictures");
File.WriteAllText(sHtmlFile, sHtmlFileContents);

Posts: 6
Joined: Fri May 11, 2012 9:18 am

Wed Jun 27, 2012 6:39 am

That's a good solution. Thanks for sharing here.
e-iceblue support
User avatar

iceblue support
Posts: 240
Joined: Tue Dec 21, 2010 2:56 am

Return to Spire.Doc