Skip to content

ainilili/html2docx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Convert HTML to DOCX

Install

go get github.com/ainilili/html2docx

Usage

package main

import (
	"github.com/ainilili/html2docx"
	"log"
	"os"
)

func main() {
	source := `<!DOCTYPE html>
<html>
<head>
	<title>我的网页</title>
</head>
<body>
	<h1>欢迎来到我的网页</h1>
	<p>这是一个简单的HTML文档。</p>
</body>
</html>`
	dist, err := html2docx.Convert([]byte(source))
	if err != nil {
		log.Fatalln(err)
	}
	err = os.WriteFile("test.docx", dist, 0666)
	if err != nil {
		panic(err)
	}
}