Categorygithub.com/Qingluan/doc-go
repository
0.0.4
Repository: https://github.com/qingluan/doc-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

DESC

a pure go to read doc(97 ) / docx (2007)

feature

  • read text in docx
  • read text in doc
  • read table within docx
  • read table within doc
  • markdown to docx
  • read image within docx
  • read image within doc

TODO

  • read docx with table and image and link

USAGE

package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/Qingluan/doc-go/docparse"
	"github.com/Qingluan/doc-go/docxgen"
	"github.com/Qingluan/doc-go/docxparse"
)

func main() {
	f := os.Args[1]
	if strings.HasSuffix(f, ".docx") {
		res := docxparse.ReadDocx(f)
		for _, p := range res {
			fmt.Println(p)
		}

	} else if strings.HasSuffix(f, ".doc") {
		//doc
		res := docparse.ReadDoc(f)
		for _, p := range res {
			fmt.Println(p)
		}
	} else if strings.HasSuffix(f, ".md") {
		create := docxgen.NewDocCreator()
		content, _ := os.ReadFile(f)
		create.FromMarkdown(string(content)).ExportDocx("out.docx")
		fmt.Println("docx文件已生成:", "out.docx")
	}

}