-
Notifications
You must be signed in to change notification settings - Fork 45
en Example Projects
zero edited this page Jun 5, 2025
·
1 revision
This document showcases complete example projects demonstrating practical usage of WordZero in real-world scenarios.
All example projects are located in the examples/ directory:
examples/
├── basic/ # Basic document creation
├── advanced_features/ # Advanced WordZero features
├── table/ # Table manipulation examples
├── style_demo/ # Style system demonstration
├── formatting/ # Text formatting examples
├── template_demo/ # Template system usage
├── markdown_demo/ # Markdown conversion
└── page_settings/ # Page configuration examples
Location: examples/basic/
This example demonstrates the most fundamental WordZero operations:
package main
import (
"fmt"
"log"
"github.com/ZeroHawkeye/wordZero/pkg/document"
"github.com/ZeroHawkeye/wordZero/pkg/style"
)
func main() {
fmt.Println("Creating basic Word document...")
// Create new document
doc := document.New()
// Add title
title := doc.AddParagraph("My First WordZero Document")
title.SetStyle(style.StyleTitle)
// Add subtitle
subtitle := doc.AddParagraph("Learning WordZero with Go")
subtitle.SetStyle(style.StyleSubtitle)
// Add content
content := doc.AddParagraph("This document was created using WordZero, a powerful Go library for Word document manipulation.")
content.SetStyle(style.StyleNormal)
// Save document
if err := doc.Save("examples/output/basic_document.docx"); err != nil {
log.Fatalf("Failed to save document: %v", err)
}
fmt.Println("Document created successfully: examples/output/basic_document.docx")
}What you'll learn:
- Document creation
- Adding paragraphs
- Applying basic styles
- Saving documents
- Go 1.19 or higher installed
- WordZero library installed:
go get github.com/ZeroHawkeye/wordZero
# Navigate to the project root
cd wordZero
# Run basic example
go run examples/basic/main.go
# Run advanced features example
go run examples/advanced_features/main.goAll examples save their output to the examples/output/ directory.
These examples provide a comprehensive foundation for using WordZero in your projects.