Comments (3)
answered via email
from mscfb.
Ok, same issue now..
from mscfb.
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)
- cycles possible when building ministream sector chain HOT 1
- how to read images from the Compound File? HOT 6
- API change: model after archive/zip HOT 2
- rather than reflect based loading of headers, use a special purpose function
- add a benchmark to verify perf chgs
- unused directory entries break sibling traversal
- Ability to modify content in a stream HOT 6
- Add license
- panic on govdocs file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mscfb.