Skip to content

Commit 59710df

Browse files
committed
Added script changes
1 parent f04577a commit 59710df

1 file changed

Lines changed: 15 additions & 25 deletions

File tree

  • Paragraphs/Replace-image-with-new-EMF/.NET/Replace-image-with-new-EMF
Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
11
using Syncfusion.DocIO;
22
using Syncfusion.DocIO.DLS;
3+
using System.Collections.Generic;
34
using System.IO;
45

5-
namespace Change_bullet_symbol_in_list
6+
using (WordDocument document = new WordDocument(Path.Combine(@"../../../Data/input.docx"), FormatType.Docx))
67
{
7-
class Program
8+
//Find picture in document
9+
List<Entity> pictures = document.FindAllItemsByProperty(EntityType.Picture, null, null);
10+
11+
if (pictures != null)
812
{
9-
static void Main(string[] args)
13+
//Iterate and replace image
14+
foreach (Entity entity in pictures)
1015
{
11-
//Open the file as a stream.
12-
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
13-
{
14-
//Load the file stream into a Word document.
15-
using (WordDocument document = new WordDocument(inputStream, FormatType.Docx))
16-
{
17-
//Access the list style in a Word document.
18-
ListStyle style = document.ListStyles[0];
19-
WListLevel levelOne = style.Levels[0];
20-
//Define the character and pattern for level 1.
21-
levelOne.PatternType = ListPatternType.Bullet;
22-
levelOne.BulletCharacter = "\u0076";
23-
levelOne.CharacterFormat.FontName = "Wingdings";
24-
//Create a file stream.
25-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Sample.docx"), FileMode.Create, FileAccess.ReadWrite))
26-
{
27-
//Save the Word document to the file stream.
28-
document.Save(outputFileStream, FormatType.Docx);
29-
}
30-
}
31-
}
16+
WPicture picture = entity as WPicture;
17+
FileStream imageStream = new FileStream(@"../../../Data/Image.emf", FileMode.Open, FileAccess.ReadWrite);
18+
picture.LoadImage(imageStream);
19+
imageStream.Close();
20+
3221
}
3322
}
34-
}
23+
document.Save(@"../../../Output/output.docx", FormatType.Docx);
24+
}

0 commit comments

Comments
 (0)