Fluent API
Complete fluent API reference for WordDocument — all methods organized by category
Lifecycle
word()
word()word() // new empty document
word( "/path/to/file.docx" ) // open existing file
word( text="Hello" ) // create from text
word( markdown="## Title" ) // create from Markdown
word( html="<h1>Title</h1>" ) // create from HTML.open( path )
.open( path )Argument
Type
Description
word().open( "/path/to/file.docx" ).save( [path] )
.save( [path] )Argument
Type
Description
.toBytes()
.toBytes().toBase64()
.toBase64().writeTo( stream )
.writeTo( stream )Argument
Type
Description
.getDocument()
.getDocument().close()
.close()Importers
.fromText( text )
.fromText( text )Argument
Type
Description
.fromMarkdown( markdown )
.fromMarkdown( markdown )Argument
Type
Description
.fromHTML( html )
.fromHTML( html )Argument
Type
Description
Exporters
.toText()
.toText().toMarkdown()
.toMarkdown().toHTML()
.toHTML()Content
.addHeading( text, level )
.addHeading( text, level )Argument
Type
Description
.addParagraph( text, [options] )
.addParagraph( text, [options] )Argument
Type
Description
.addPageBreak()
.addPageBreak().addSectionBreak()
.addSectionBreak().newLine()
.newLine()Tables
.addTable( data )
.addTable( data )Argument
Type
Description
Images
.addImage( path, [widthCm], [heightCm] )
.addImage( path, [widthCm], [heightCm] )Argument
Type
Description
.addImage( path, options )
.addImage( path, options )Option
Type
Description
.addImage( bytes, fileName, [widthCm], [heightCm] )
.addImage( bytes, fileName, [widthCm], [heightCm] )Argument
Type
Description
.addImageBase64( base64Str, fileName )
.addImageBase64( base64Str, fileName )Argument
Type
Description
.addImageFromUrl( url, [widthCm], [heightCm] )
.addImageFromUrl( url, [widthCm], [heightCm] )Argument
Type
Description
Lists
.addUnorderedList( items )
.addUnorderedList( items )Argument
Type
Description
.addOrderedList( items )
.addOrderedList( items )Argument
Type
Description
Hyperlinks
.addHyperlink( text, url )
.addHyperlink( text, url )Argument
Type
Description
Page Setup
.margins( top, bottom, left, right )
.margins( top, bottom, left, right )Argument
Type
Description
.margins( options )
.margins( options )Option
Type
Description
.pageSize( size )
.pageSize( size )Argument
Type
Description
.orientation( orientation )
.orientation( orientation )Argument
Type
Description
.header( text )
.header( text )Argument
Type
Description
.footer( text )
.footer( text )Argument
Type
Description
Template Population
.populate( data )
.populate( data )Argument
Type
Description
.replaceText( find, replace )
.replaceText( find, replace )Argument
Type
Description
.setBookmark( name, value )
.setBookmark( name, value )Argument
Type
Description
.setContentControl( tag, value )
.setContentControl( tag, value )Argument
Type
Description
Document Properties
.setTitle( title )
.setTitle( title )Argument
Type
Description
.setAuthor( author )
.setAuthor( author )Argument
Type
Description
.setSubject( subject )
.setSubject( subject )Argument
Type
Description
.setKeywords( keywords )
.setKeywords( keywords )Argument
Type
Description
.setDefaultFont( family, size )
.setDefaultFont( family, size )Argument
Type
Description
Security & Advanced
.addWatermark( text )
.addWatermark( text )Argument
Type
Description
.protect( password )
.protect( password )Argument
Type
Description
.addTableOfContents()
.addTableOfContents()Fluent Helpers
.tap( action )
.tap( action )Argument
Type
Description
.when( condition, action )
.when( condition, action )Argument
Type
Description
📚 Related Resources
User GuideAdvanced FeaturesFormattingBuilt-In FunctionsLast updated
Was this helpful?
