GithubHelp home page GithubHelp logo

Comments (3)

richardlehane avatar richardlehane commented on June 20, 2024

answered via email

from mscfb.

infodusha avatar infodusha commented on June 20, 2024

Ok, same issue now..

from mscfb.

richardlehane avatar richardlehane commented on June 20, 2024

To get the bytes out of that stream you could do something like this:

package main

import (
"io"
"io/ioutil"
"log"
"os"

"github.com/richardlehane/mscfb"

)

func main() {
file, err := os.Open("test/test.doc")
defer file.Close()
if err != nil {
log.Fatal(err)
}
doc, err := mscfb.New(file)
if err != nil {
log.Fatal(err)
}
for entry, err := doc.Next(); err == nil; entry, err = doc.Next() {
if entry.Name == "WordDocument" {
buf, err := ioutil.ReadAll(entry)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(buf))
}
}
}

BUT

"... [this] package only implements the MS-CFB spec (https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cfb/53989ce4-7b05-4f8d-829b-d08d6148375b) which is a common container format used by a lot of different Windows software. It doesn't implement the MS Word spec (MS-DOC) - so can't help you identify byte ranges of the runs of text in a word doc. To do something like that, you'd need to look at the MS-DOC spec (https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-doc/d7fae142-670d-4cd5-869a-708366984a71) - you'd probably need to work out how to interpret the File Information Block structure (FIB) at the start of the WordDocument stream to get offsets for where the text entries are in the stream. That's probably quite a bit of work. The other option might be just to iterate over the byte slice and delete any bytes not in the ASCII range (this won't work if the doc stream has UTF16 or some other encoding)? e.g.

buf2 := make([]byte, 0, len(buf))
for _, c := range buf {
if c > 6 && c < 128 {
buf2 = append(buf2, c)
}"

from mscfb.

Related Issues (10)

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.