Skip to content

Commit

Permalink
Merge pull request #30 from gomutex/readme-update
Browse files Browse the repository at this point in the history
readme update
  • Loading branch information
gomutex authored Jun 28, 2024
2 parents 78eaa67 + 6f68ab2 commit f77a62c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Godocx is a Golang library for creating and modifying DOCX (Microsoft Word) docu
Here's a simple example of how you can use Godocx to create and modify DOCX documents:

```go
// More examples in separate repository
// https://github.com/gomutex/godocx-examples

package main

import (
Expand All @@ -19,21 +22,26 @@ import (

func main() {
// Open an existing DOCX document
docx, err := godocx.OpenDocument("./testdata/test.docx")
// docx, err := godocx.OpenDocument("./testdata/test.docx")

// Create New Document
docx, err := godocx.NewDocument()
if err != nil {
log.Fatal(err)
}

// Add a new paragraph to the document
_ = docx.AddParagraph("Hello World")
p := docx.AddEmptyParagraph()
_ = p.AddText("Add Paragraph and get `Run` instance")
_ = p.AddText("Add Paragraph and get `Run` instance. ")
r := p.AddText("This sentence is in Bold")
r.Bold(true)

// Add Heading
docx.AddHeading("Example Heading", 1) // Heading text and level

// Save the modified document to a new file
err = docx.SaveTo("./test_modified.docx")
err = docx.SaveTo("sample.docx")
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit f77a62c

Please sign in to comment.