@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
230 lines (229 loc) • 8.31 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { PdfXmpSchema } from './pdf-xmp-schema';
import { PdfXmpSchemaType } from '../enumerator';
/**
* Represents the base schema for PDF document metadata properties.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Create XMP metadata
* let xmp: PdfXmpMetadata = new PdfXmpMetadata();
* // Sets PDF keywords
* xmp.pdfSchema.keywords = 'sample, pdf, metadata';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
var PdfSchema = /** @class */ (function (_super) {
__extends(PdfSchema, _super);
/**
* Initializes a new `PdfSchema` instance.
*
* @private
* @param {PdfXmpMetadata} xmp Optional parent PdfXmpMetadata reference.
*/
function PdfSchema(xmp) {
var _this = _super.call(this, xmp) || this;
_this._prefix = 'pdf';
_this._name = 'PDF';
return _this;
}
Object.defineProperty(PdfSchema.prototype, "schemaType", {
/**
* Gets the schema type.
*
* @returns {PdfXmpSchemaType} The schema type.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets the PDF Schema from the XMP metadata
* let pdfSchema: PdfSchema = xmpMetadata.pdfSchema;
* // Gets the schema type
* let schemaType: PdfXmpSchemaType = pdfSchema.schemaType;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
return PdfXmpSchemaType.pdf;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfSchema.prototype, "keywords", {
/**
* Gets the PDF keywords.
*
* @returns {string} The PDF keywords.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets the xmp metadata
* let xmpMetadata = documentProperties.xmpMetadata;
* // Access keywords from PDF schema
* let keywords: string = xmpMetadata.pdfSchema.keywords;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._keywords) {
this._keywords = this._getProperty('pdf:Keywords');
}
return this._keywords;
},
/**
* Sets the PDF keywords.
*
* @param {string} value The PDF keywords to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets the xmp metadata
* let xmp = documentProperties.xmpMetadata;
* // Sets keywords
* xmp.pdfSchema.keywords = 'sample, pdf, metadata';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._keywords = value;
this._setProperty('pdf:Keywords', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfSchema.prototype, "pdfVersion", {
/**
* Gets the PDF version.
*
* @returns {string} The PDF version.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets the xmp metadata
* let xmpMetadata = documentProperties.xmpMetadata;
* // Access PDF version from PDF schema
* let pdfVersion: string = xmpMetadata.pdfSchema.pdfVersion;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._pdfVersion) {
this._pdfVersion = this._getProperty('pdf:PDFVersion');
}
return this._pdfVersion;
},
/**
* Sets the PDF version.
*
* @param {string} value The PDF version to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets the xmp metadata
* let xmp = documentProperties.xmpMetadata;
* // Sets PDF version
* xmp.pdfSchema.pdfVersion = '1.7';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._pdfVersion = value;
this._setProperty('pdf:PDFVersion', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfSchema.prototype, "producer", {
/**
* Gets the PDF producer.
*
* @returns {string} The PDF producer.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets the xmp metadata
* let xmpMetadata = documentProperties.xmpMetadata;
* // Access producer from PDF schema
* let producer: string = xmpMetadata.pdfSchema.producer;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._producer) {
this._producer = this._getProperty('pdf:Producer');
}
return this._producer;
},
/**
* Sets the PDF producer.
*
* @param {string} value The PDF producer to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets the xmp metadata
* let xmp = documentProperties.xmpMetadata;
* // Sets producer
* xmp.pdfSchema.producer = 'Syncfusion EJ2 PDF';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._producer = value;
this._setProperty('pdf:Producer', value);
},
enumerable: true,
configurable: true
});
return PdfSchema;
}(PdfXmpSchema));
export { PdfSchema };