Skip to content

Commit

Permalink
Some .pages file include a PDF or XML version
Browse files Browse the repository at this point in the history
See Issue #8

This captures some of these.
  • Loading branch information
mish15 committed Apr 27, 2015
1 parent 5f61ea5 commit 3e47cd5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,26 @@ func ConvertPages(input io.Reader) (string, map[string]string) {
log.Println("ioutil.ReadAll:", err)
return "", nil
}

r, err := zip.NewReader(bytes.NewReader(inputBytes), int64(len(inputBytes)))
if err != nil {
log.Println("zip.NewReader:", err)
return "", nil
}

for _, f := range r.File {
if strings.HasSuffix(f.Name, "Preview.pdf") {
// There is a preview PDF version we can use
if rc, err := f.Open(); err == nil {
return ConvertPdf(rc)
}
}
if f.Name == "index.xml" {
// There's an XML version we can use
if rc, err := f.Open(); err == nil {
return ConvertXml(rc)
}
}
if f.Name == "Index/Document.iwa" {
rc, _ := f.Open()
defer rc.Close()
Expand Down

0 comments on commit 3e47cd5

Please sign in to comment.