Forums

Overview » C# » Insert an Image into the Footer in Word with C#
Reply

Insert an Image into the Footer in Word with C#

tom linus
Newbie



Since: 18 Jan 2011
Posts: 21
Posted 18 Feb 2011 10:31:29

This article introduces how to insert an image and some relative settings of C# Word footer. First I want to tell you how to use footer in MS Word.
After you launch a Word document, you can click the View in the main menu, and then choose the Header and Footer button. At this moment, you can set some basic property of the footer. For example, you can set the author, page number and so on of the footer. You can research it by yourself for your own requirement.
Now I want to tell you how to insert an image into the footer via Spire.Doc. Here I suppose you have created a paragraph as the footer. At this time, you should create another paragraph in the footer paragraph. And then, select an image from your PC. After inserting it into the paragraph, you can set the property of the image. And then, you can also append some text in the footer. It won’t conflict with the picture. In my demo, I add a border of the footer to make the footer beautiful.
Here is the C# code:
C#:
//Insert an image into footer paragraph
Paragraph footer = footer.AddParagraph();
DocPicture image = footer.AppendPicture(Image.FromFile("Sky.jpg");

//The alignment of the footer picture
image.TextWrappingStyle = TextWrappingStyle.Behind;
image.HorizontalOrigin = HorizontalOrigin.Page;
image.HorizontalAlignment = ShapeHorizontalAlignment.Center;
image.VerticalOrigin = VerticalOrigin.Page;
image.VerticalAlignment = ShapeVerticalAlignment.Bottom;

//Set the text of the footer
TextRange text = footer.AppendText("Demo of Spire.Doc";
text.CharacterFormat.FontName = "Arial";
text.CharacterFormat.FontSize = 11;
text.CharacterFormat.Italic = false;
footer.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;

//Add a border of the footer
footer.Format.Borders.Bottom.BorderType = Spire.Doc.Documents.BorderStyle.Single;
footer.Format.Borders.Bottom.Space = 0.06F;


Edited by - tom linus on 24 Feb 2011  05:43:45

This article introduces how to insert an image and some relative settings of C# Word footer. First I want to tell you how to use footer in MS Word.
After you launch a Word document, you can click the View in the main menu, and then choose the Header and Footer button. At this moment, you can set some basic property of the footer. For example, you can set the author, page number and so on of the footer. You can research it by yourself for your own requirement.
Now I want to tell you how to insert an image into the footer via Spire.Doc. Here I suppose you have created a paragraph as the footer. At this time, you should create another paragraph in the footer paragraph. And then, select an image from your PC. After inserting it into the paragraph, you can set the property of the image. And then, you can also append some text in the footer. It won’t conflict with the picture. In my demo, I add a border of the footer to make the footer beautiful.
Here is the C# code:
C#:
//Insert an image into footer paragraph
Paragraph footer = footer.AddParagraph();
DocPicture image = footer.AppendPicture(Image.FromFile("Sky.jpg");

//The alignment of the footer picture
image.TextWrappingStyle = TextWrappingStyle.Behind;
image.HorizontalOrigin = HorizontalOrigin.Page;
image.HorizontalAlignment = ShapeHorizontalAlignment.Center;
image.VerticalOrigin = VerticalOrigin.Page;
image.VerticalAlignment = ShapeVerticalAlignment.Bottom;

//Set the text of the footer
TextRange text = footer.AppendText("Demo of Spire.Doc";
text.CharacterFormat.FontName = "Arial";
text.CharacterFormat.FontSize = 11;
text.CharacterFormat.Italic = false;
footer.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;

//Add a border of the footer
footer.Format.Borders.Bottom.BorderType = Spire.Doc.Documents.BorderStyle.Single;
footer.Format.Borders.Bottom.Space = 0.06F;


Edited by - tom linus on 24 Feb 2011  05:43:45
tom linus
Newbie



Since: 18 Jan 2011
Posts: 21
Replied 24 Feb 2011 05:41:16
It's useful.[]

Reply to this topic

Message
Reply
Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency