# officeprops

> Manipulate MS office and Open Office metadata

Latest version **1.1.5** (published 2018-06-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install officeprops
pnpm add officeprops
yarn add officeprops
bun add officeprops
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2018-06-23 |
| First published | 2018-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.2 MB |
| Known vulnerabilities | 0 (+18 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Torkel Velure |
| Maintainers | torkelv |
| Keywords | metadata, office, document, properties |

## Links

- npm: https://www.npmjs.com/package/officeprops
- Repository: https://github.com/TorkelV/officeprops
- Homepage: https://github.com/TorkelV/officeprops#readme
- Issues: https://github.com/TorkelV/officeprops/issues
- npm.io page: https://npm.io/package/officeprops

## Dependencies (2)

- [jszip](https://npm.io/package/jszip.md) 3.1.5
- [xmldom](https://npm.io/package/xmldom.md) 0.1.27

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 1.1.5 (latest) — 2018-06-23
- 1.1.0 — 2018-05-29
- 1.0.1 — 2018-05-21
- 1.0.0 — 2018-05-19
- 0.6.1 — 2018-05-18
- 0.6.0 — 2018-05-18
- 0.5.0 — 2018-05-17

## README

# OfficeProps.js

A JavaScript library used to extract, edit or remove metadata in Microsoft Office and Open Office files.



#### Supports:
 * docx, dotx, docm, dotm
 * xlsx, xlsm, xlsb, xltm, xltx
 * pptx, ppsx, ppsm, pptm, potm, potx
 * ods, odt, odp

## Install:
Officeprops relies on [JSZip](https://stuk.github.io/jszip/) which has be included alongside this package if not using node.

Node:
```
npm install officeprops
```
Or include via cdn:
```
<script src='https://cdn.jsdelivr.net/npm/jszip@3.1.5/dist/jszip.min.js'></script>
<script src='https://cdn.jsdelivr.net/npm/officeprops@1.1.5/src/officeprops.js'></script>
```



## Usage:

The package adds a global "OFFICEPROPS" variable.

All functions take a [File](https://developer.mozilla.org/en-US/docs/Web/API/File) or [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) as parameter, or a [Buffer](https://nodejs.org/api/buffer.html#buffer_class_buffer) in Node.


##### Get metadata:
```javascript
OFFICEPROPS.getData(file).then(function(metadata){
    console.log(metadata.editable);
    console.log(metadata.readOnly);
}
```

##### Metadata Format:
Open office property names are translated to MS Office names. e.g. "editing-duration" becomes "totalTime".  
Returns the actual value, as well as a translated one for each property.
```javascript
metadata = {
    editable: {
        totalTime: {
            value: "PT3M43S", //actual value
            tvalue: "3 minutes", //translated value
            xmlPath: "office:meta/meta:editing-duration"
        },
        creator: {
            value: "Torkel Velure",
            tvalue: "Torkel Velure",
            xmlPath: "office:meta/meta:initial-creator"
        }
        //...see OFFICEPROPS.properties for full list of properties
    },
    readOnly: {
        slideTitles: ["Slide1, slide2, slide3"],
        titles: ["title1", "title2"]
        worksheets: ["sheet1"]
    }
}
```

##### Edit metadata:

```javascript
OFFICEPROPS.getData(file).then(function(metadata){
    metadata.editable.creator.value = "New author";
    OFFICEPROPS.editData(file,metadata).then(function(officeFile){
        console.log(officeFile) // blob/nodestream containing edited file.
    }
}
```


##### Remove metadata:
```javascript
OFFICEPROPS.removeData(file).then(function(officeFile){
    console.log(officeFile) // blob/nodestream with metadata removed.
}
```

For more, see [Examples](https://github.com/TorkelV/officeprops/blob/master/src/example/index.html) or [Tests](https://github.com/TorkelV/officeprops/blob/master/src/test/officeprops.test.js)

---
_Source: https://npm.io/package/officeprops · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
