11using Syncfusion . DocIO ;
22using Syncfusion . DocIO . DLS ;
3+ using System . Collections . Generic ;
34using 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