Files
docx-js/ts/properties/index.ts

36 lines
1.4 KiB
TypeScript
Raw Normal View History

2016-04-03 20:00:30 +01:00
import {XmlComponent} from "../docx/xml-components";
2016-05-01 22:49:40 +01:00
import {DocumentAttributes} from "../docx/document/document-attributes";
2016-04-03 20:00:30 +01:00
import {Title, Subject, Creator, Keywords, Description, LastModifiedBy, Revision, Created, Modified} from "./components";
interface PropertiesOptions {
title?: string;
subject?: string;
creator?: string;
keywords?: string;
description?: string;
lastModifiedBy?: string;
revision?: string;
}
2016-04-09 20:16:35 +01:00
export class Properties extends XmlComponent {
2016-04-03 20:00:30 +01:00
constructor(options: PropertiesOptions) {
2016-04-09 20:16:35 +01:00
super("cp:coreProperties");
this.root.push(new DocumentAttributes({
2016-04-03 20:00:30 +01:00
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
dc: "http://purl.org/dc/elements/1.1/",
dcterms: "http://purl.org/dc/terms/",
dcmitype: "http://purl.org/dc/dcmitype/",
xsi: "http://www.w3.org/2001/XMLSchema-instance"
}));
2016-04-09 20:16:35 +01:00
this.root.push(new Title(options.title));
this.root.push(new Subject(options.subject));
this.root.push(new Creator(options.creator));
this.root.push(new Keywords(options.keywords));
this.root.push(new Description(options.description));
this.root.push(new LastModifiedBy(options.lastModifiedBy));
this.root.push(new Revision(options.revision));
this.root.push(new Created());
this.root.push(new Modified());
2016-04-03 20:00:30 +01:00
}
2016-04-03 01:44:18 +01:00
}