Giter Site home page Giter Site logo

go-docc's Introduction

docc

Simple ".docx" converter implemented by Go. Convert ".docx" to plain text.

Note

This repository is an alpha version. Some disruptive changes could be applied.

License

MIT

Features

  • Less dependency.
  • No need for Microsoft Office.
  • Only on limited environment, also ".doc" could be converted.
    • Windows in which MS Office has been installed.

Usage

As a package

This is a simple example to read all paragraphs.

package main

import "github.com/tenkoh/go-docc"

func main(){
    fp := filepath.Clean("./target.docx")
    r, err := NewReader(fp)
    if err != nil {
        panic(err)
    }
    defer r.Close()
    ps, _ := r.ReadAll()
    // do something with ps:[]string
}

If you want read the document by a paragraph, the below example is useful.

package main

import "github.com/tenkoh/go-docc"

func main(){
    fp := filepath.Clean("./target.docx")
    r, err := NewReader(fp)
    if err != nil {
        panic(err)
    }
    defer r.Close()
    
    for {
        p, err := r.Read()
        if err == io.EOF {
            return
        } else if err != nil {
            panic(err)
        }
        // do something with p:string
    }
}

Before compiling, you shall execute go mod tidy or go get github.com/tenkoh/go-doccto get this package.

As a binary

go install is available.

go install github.com/tenkoh/go-docc/cmd/docc@latest

Then, docc command could be used. This is a simple example.

docc target.docx > plain.txt

Contribution

Your contribution is really welcomed!

Author

tenkoh

go-docc's People

Contributors

gogrisohil avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.