88using System . Threading . Tasks ;
99using System . Xml . Linq ;
1010using DocSharp . Helpers ;
11- using DocSharp ;
11+ using DocSharp . Primitives ;
1212using DocumentFormat . OpenXml ;
1313using DocumentFormat . OpenXml . Packaging ;
14- using DocumentFormat . OpenXml . Wordprocessing ;
1514using W = DocumentFormat . OpenXml . Wordprocessing ;
1615using EpubCore ;
1716using HtmlToOpenXml ;
@@ -104,9 +103,9 @@ public async Task BuildDocxAsync(Stream input, WordprocessingDocument targetDocu
104103 {
105104 // Initialize document
106105 var mainPart = targetDocument . MainDocumentPart ?? targetDocument . AddMainDocumentPart ( ) ;
107- mainPart . Document ??= new Document ( ) ;
106+ mainPart . Document ??= new W . Document ( ) ;
108107 mainPart . Document . RemoveAllChildren ( ) ;
109- var body = mainPart . Document . AppendChild ( new Body ( ) ) ;
108+ var body = mainPart . Document . AppendChild ( new W . Body ( ) ) ;
110109
111110 // Initialize HTML to DOCX converter
112111 var converter = new HtmlConverter ( mainPart )
@@ -152,9 +151,9 @@ public async Task BuildDocxAsync(Stream input, WordprocessingDocument targetDocu
152151 // Before each chapter, add a bookmark in DOCX to make internal links work
153152 string anchorName = $ "_{ fileName . Replace ( ' ' , '_' ) } ";
154153 int id = new Random ( ) . Next ( 100000 , 999999 ) ; // TODO: improve id generation
155- body . AppendChild ( new Paragraph ( [
156- new BookmarkStart ( ) { Name = anchorName , Id = id . ToString ( ) } ,
157- new BookmarkEnd ( ) { Id = id . ToString ( ) }
154+ body . AppendChild ( new W . Paragraph ( [
155+ new W . BookmarkStart ( ) { Name = anchorName , Id = id . ToString ( ) } ,
156+ new W . BookmarkEnd ( ) { Id = id . ToString ( ) }
158157 ] ) ) ;
159158
160159 // Parse the HTML body, convert to Open XML and append to the DOCX.
@@ -163,18 +162,18 @@ public async Task BuildDocxAsync(Stream input, WordprocessingDocument targetDocu
163162 if ( PageBreakAfterChapters )
164163 {
165164 // Add a page break after each chapter if desired.
166- body . AppendChild ( new Paragraph ( new Run ( new Break ( ) { Type = BreakValues . Page } ) ) ) ;
165+ body . AppendChild ( new W . Paragraph ( new W . Run ( new W . Break ( ) { Type = W . BreakValues . Page } ) ) ) ;
167166 }
168167 }
169168
170169 // Add default section properties
171- body . AppendChild ( new SectionProperties (
170+ body . AppendChild ( new W . SectionProperties (
172171 new W . PageSize ( )
173172 {
174173 Width = ( uint ) ( ( PageSize ?? PageSize . Default ) . WidthTwips ( ) ) ,
175174 Height = ( uint ) ( ( PageSize ?? PageSize . Default ) . HeightTwips ( ) ) ,
176175 } ,
177- new PageMargin ( )
176+ new W . PageMargin ( )
178177 {
179178 // Notes:
180179 // - PageMargin uses uint for Left and Right margins, and int for top and bottom (enforced by Open XML SDK)
0 commit comments