mirror of
https://github.com/jzillmann/pdf-to-markdown.git
synced 2025-01-17 02:58:30 +01:00
24 lines
475 B
TypeScript
24 lines
475 B
TypeScript
export default class Metadata {
|
|
original: object;
|
|
|
|
constructor(original: object) {
|
|
this.original = original;
|
|
}
|
|
|
|
title() {
|
|
return this.extract('Title', 'dc:title');
|
|
}
|
|
|
|
author() {
|
|
return this.extract('Author', 'dc:creator');
|
|
}
|
|
|
|
private extract(infoName: string, metadataKey: string) {
|
|
const metadata = this.original['metadata'];
|
|
if (metadata) {
|
|
return metadata.get(metadataKey);
|
|
}
|
|
return this.original['info'][infoName];
|
|
}
|
|
}
|