metagopenoffice

package module
v0.0.0-...-5f50564 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

metagopenoffice

Build Status Go Report Card

Open Office metadata extractor written in Go

The main features of metagopenoffice are:

  • Read metadata of odt files.
  • Read metadata of odp files.
  • Read metadata of ods files.

How to use ?


package main

import (
	"fmt"
	"log"
	"os"

	"github.com/kevinborras/metagopenoffice"
)

func main() {

	file, err := os.Open("../test/test.odt")
	if err != nil {
		log.Fatal(err)
	}
	file.Close()
	content, err := gopenoffice.GetMetada(file)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("Generator: ", content.Meta.Generator)
	fmt.Println("InitialCreator: ", content.Meta.InitialCreator)
	fmt.Println("CreationDate: ", content.Meta.CreationDate)
	fmt.Println("Creator: ", content.Meta.Creator)
	fmt.Println("Date: ", content.Meta.Date)
	fmt.Println("Language: ", content.Meta.Language)
	fmt.Println("EditingCycles: ", content.Meta.EditingCycles)
	fmt.Println("EditingDuration: ", content.Meta.EditingDuration)
	fmt.Println("Title: ", content.Meta.Title)
	fmt.Println("Description: ", content.Meta.Description)
	fmt.Println("Subject: ", content.Meta.Subject)
	fmt.Println("PrintDate: ", content.Meta.PrintDate)
	fmt.Println("Keyword: ", content.Meta.Keyword)
	fmt.Println()
	fmt.Println("PageCount: ", content.Meta.Stats.PageCount)
	fmt.Println("ImageCount: ", content.Meta.Stats.ImageCount)
	fmt.Println("ObjectCount: ", content.Meta.Stats.ObjectCount)
	fmt.Println("ParagraphCount: ", content.Meta.Stats.ParagraphCount)
	fmt.Println("WordCount: ", content.Meta.Stats.WordCount)
	fmt.Println("CharCount: ", content.Meta.Stats.CharCount)

}

Output

Generator:  StarOffice/8_Beta$Linux OpenOffice.org_project/680m66$Build-8852$CWS-sdksample
InitialCreator:  Jürgen Schmidt
CreationDate:  2002-12-18T12:28:35
Creator:  Jürgen Schmidt
Date:  2002-12-18T12:31:15
Language:  en-US
EditingCycles:  3
EditingDuration:  PT2M40S
Title:
Description:
Subject:
PrintDate:
Keyword:

PageCount:  1
ImageCount:  0
ObjectCount:  0
ParagraphCount:  7
WordCount:  77
CharCount:  511

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Generator       string     `xml:"generator"`
	Title           string     `xml:"title"`
	Description     string     `xml:"description"`
	Subject         string     `xml:"subject"`
	PrintDate       string     `xml:"print-date"`
	Keyword         string     `xml:"keyword"`
	InitialCreator  string     `xml:"initial-creator"`
	CreationDate    string     `xml:"creation-date"`
	Creator         string     `xml:"creator"`
	Date            string     `xml:"date"`
	Language        string     `xml:"language"`
	EditingCycles   string     `xml:"editing-cycles"`
	EditingDuration string     `xml:"editing-duration"`
	Stats           Statistics `xml:"document-statistic"`
}

Metadata is a struct that contains metadata fields

type OpenOfficeXML

type OpenOfficeXML struct {
	Meta Metadata `xml:"meta"`
}

OpenOfficeXML contains the fields of te file meta.xml

func GetMetada

func GetMetada(document *os.File) (metadata OpenOfficeXML, err error)

GetMetada function

type Statistics

type Statistics struct {
	PageCount      int `xml:"page-count,attr"`
	ImageCount     int `xml:"image-count,attr"`
	ObjectCount    int `xml:"object-count,attr"`
	ParagraphCount int `xml:"paragraph-count,attr"`
	WordCount      int `xml:"word-count,attr"`
	CharCount      int `xml:"character-count,attr"`
}

Statistics is a struct that contains the document-statistics

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL