Skip to content

Commit

Permalink
Start using fileconversion for docx 2 txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Vytek committed Sep 4, 2023
1 parent 6d988da commit d424a3b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions opencrucible.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package opencrucible
import (
"bytes"
"errors"
"fmt"
"os"

"github.com/gabriel-vasile/mimetype"
"github.com/h2non/filetype"
Expand Down Expand Up @@ -52,13 +54,15 @@ func RTFParseToString(StreamToParse []byte) (string, error) {
return rtf, err
}

func DOCXParseToString(StreamToParse []byte) (string, error) {
// If no StreamToDetect was given, return an error with a message.
if len(StreamToParse) == 0 {
return "", errors.New("stream to parse is empty")
func DOCXFileParseToString(FileToParse string) (string, error) {
// extract text from an XLSX file
file, err := os.Open(FileToParse)
if err != nil {
return "", errors.New(fmt.Sprintf("Error opening file: %s\n", err))
}
docx, err := cat.FromBytes(StreamToParse)
return docx, err

defer file.Close()
stat, _ := file.Stat()
}

func ODTParseToString(StreamToParse []byte) (string, error) {
Expand Down

0 comments on commit d424a3b

Please sign in to comment.