Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141335 | Dec 6,2018 11:16 AM UTC | Dec 12,2018 05:16 PM UTC | ASP.NET Web Forms | 3 |
![]() |
Tags: DocIO |
//Creates a Word document.
WordDocument document = new WordDocument();
//Adds a section and paragraph in the document.
document.EnsureMinimal();
//Appends picture in the paragraph.
IWPicture picture = document.LastParagraph.AppendPicture(Image.FromFile("image.jpg"));
//Sets vertical origin as paragraph to enable move with text property.
picture.VerticalOrigin = VerticalOrigin.Paragraph;
//Sets wrapping style for picture.
picture.TextWrappingStyle = TextWrappingStyle.Square;
//Appends shape in the paragraph.
Shape shape = document.LastParagraph.AppendShape(AutoShapeType.Rectangle, 70, 50);
//Sets vertical origin as paragraph to enable move with text property.
shape.VerticalOrigin = VerticalOrigin.Paragraph;
//Sets wrapping style for shape.
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Square;
//Appends textbox in the paragraph.
IWTextBox textBox = document.LastParagraph.AppendTextBox(70, 50);
//Sets vertical origin as paragraph to enable move with text property.
textBox.TextBoxFormat.VerticalOrigin = VerticalOrigin.Paragraph;
//Sets wrapping style for textbox.
textBox.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.Square;
//Saves the Word document.
document.Save("Sample.docx");
//Closes the Word document.
document.Close(); |
WordDocument document = new WordDocument(@"../../Data/Input.docx");
WParagraph paragraph = new WParagraph(document);
IWPicture pic = paragraph.AppendPicture(Image.FromFile(@"../../Data/input.jpg"));
pic.VerticalOrigin = VerticalOrigin.Paragraph;
pic.TextWrappingStyle = TextWrappingStyle.Square;
TextBodyPart bodyPart = new TextBodyPart(document);
bodyPart.BodyItems.Add(paragraph);
//Replaces a particular text with the text body part
document.Replace("Replace", bodyPart, false, true, true);
document.Save(@"Output.docx", FormatType.Docx); |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.