@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
631 lines (630 loc) • 22.9 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 Basic Schema.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets creator tool
* xmpMetadata.basicSchema.creatorTool = 'MyApp';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
var PdfBasicSchema = /** @class */ (function (_super) {
__extends(PdfBasicSchema, _super);
/**
* Initializes a new `PdfBasicSchema` instance.
*
* @private
* @param {PdfXmpMetadata} xmp Optional parent PdfXmpMetadata reference.
*/
function PdfBasicSchema(xmp) {
var _this = _super.call(this, xmp) || this;
_this._prefix = 'xap';
_this._name = 'Basic';
return _this;
}
Object.defineProperty(PdfBasicSchema.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 basic schema from the XMP metadata
* let basic: PdfBasicSchema = documentProperties.xmpMetadata.basicSchema;
* // Gets the schema type
* let schemaType: PdfXmpSchemaType = basic.schemaType;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
return PdfXmpSchemaType.basic;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "creatorTool", {
/**
* Gets the creator tool.
*
* @returns {string} The creatorTool value.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access creator tool from basic schema
* let creatorTool: string = xmpMetadata.basicSchema.creatorTool;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._creatorTool) {
this._creatorTool = this._getProperty('xap:CreatorTool');
}
return this._creatorTool;
},
/**
* Sets the creator tool.
*
* @param {string} value The creatorTool to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets creator tool
* xmp.basicSchema.creatorTool = 'MyApp 1.0';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._creatorTool = value;
this._setProperty('xap:CreatorTool', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "label", {
/**
* Gets the label.
*
* @returns {string} The label.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access label from basic schema
* let label: string = xmpMetadata.basicSchema.label;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._label) {
this._label = this._getProperty('xap:Label');
}
return this._label;
},
/**
* Sets the label.
*
* @param {string} value The label to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets label
* xmp.basicSchema.label = 'Sample Label';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._label = value;
this._setProperty('xap:Label', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "nickname", {
/**
* Gets the nickname.
*
* @returns {string} The nickname.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access nickname from basic schema
* let nickname: string = xmpMetadata.basicSchema.nickname;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._nickname) {
this._nickname = this._getProperty('xap:Nickname');
}
return this._nickname;
},
/**
* Sets the nickname.
*
* @param {string} value The nickname to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets nickname
* xmp.basicSchema.nickname = 'My Document';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._nickname = value;
this._setProperty('xap:Nickname', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "baseUrl", {
/**
* Gets the base URL.
*
* @returns {string} The base URL.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access base URL from basic schema
* let baseUrl: string = xmpMetadata.basicSchema.baseUrl;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._baseUrl) {
this._baseUrl = this._getProperty('xap:BaseURL');
}
return this._baseUrl;
},
/**
* Sets the base URL.
*
* @param {string} value The base URL to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets base URL
* xmp.basicSchema.baseUrl = 'https://example.com';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._baseUrl = value;
this._setProperty('xap:BaseURL', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "createDate", {
/**
* Gets the creation date.
*
* @returns {Date} The creation date.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access creation date from basic schema
* let createDate: Date = xmpMetadata.basicSchema.createDate;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._createDate) {
this._createDate = this._getProperty('xap:CreateDate');
}
return this._createDate;
},
/**
* Sets the creation date.
*
* @param {Date} value The createDate value to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets creation date
* xmp.basicSchema.createDate = new Date();
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._createDate = value;
this._setProperty('xap:CreateDate', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "modifyDate", {
/**
* Gets the modification date.
*
* @returns {Date} The modification date.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access modification date from basic schema
* let modifyDate: Date = xmpMetadata.basicSchema.modifyDate;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._modifyDate) {
this._modifyDate = this._getProperty('xap:ModifyDate');
}
return this._modifyDate;
},
/**
* Sets the modification date.
*
* @param {Date} value The modification date to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets modification date
* xmp.basicSchema.modifyDate = new Date();
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._modifyDate = value;
this._setProperty('xap:ModifyDate', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "metadataDate", {
/**
* Gets the metadata date.
*
* @returns {Date} The metadata date.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access metadata date from basic schema
* let metadataDate: Date = xmpMetadata.basicSchema.metadataDate;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._metadataDate) {
this._metadataDate = this._getProperty('xap:MetadataDate');
}
return this._metadataDate;
},
/**
* Sets the metadata date.
*
* @param {Date} value The metadata date to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets metadata date
* xmp.basicSchema.metadataDate = new Date();
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._metadataDate = value;
this._setProperty('xap:MetadataDate', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "advisory", {
/**
* Gets the advisory.
*
* @returns {string[]} The advisory.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access advisory from basic schema
* let advisory: string[] = xmpMetadata.basicSchema.advisory;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._advisory) {
this._advisory = this._getProperty('xap:Advisory');
}
return this._advisory;
},
/**
* Sets the advisory.
*
* @param {string[]} value The advisory to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets advisory
* xmp.basicSchema.advisory = ['Advisory 1', 'Advisory 2'];
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._advisory = value;
this._setProperty('xap:Advisory', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "identifier", {
/**
* Gets the identifier.
*
* @returns {string[]} The identifier.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access identifier from basic schema
* let identifier: string[] = xmpMetadata.basicSchema.identifier;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._identifier) {
this._identifier = this._getProperty('xap:Identifier');
}
return this._identifier;
},
/**
* Sets the identifier.
*
* @param {string[]} value The identifier to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets identifier
* xmp.basicSchema.identifier = ['ID-001', 'ID-002'];
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._identifier = value;
this._setProperty('xap:Identifier', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "thumbnails", {
/**
* Gets the thumbnails.
*
* @returns {PdfXmpThumbnail[]} The thumbnails.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access thumbnails from basic schema
* let thumbnails: PdfXmpThumbnail[] = xmpMetadata.basicSchema.thumbnails;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._thumbnails) {
this._thumbnails = this._getProperty('xap:Thumbnails');
}
return this._thumbnails;
},
/**
* Sets the thumbnails.
*
* @param {PdfXmpThumbnail[]} value The thumbnails to set.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Creates thumbnail array
* let thumbnailArray: PdfXmpThumbnail[] = [{width: 10, height: 10, format: 'JPEG'}]
* // Sets thumbnails (requires PdfXmpThumbnail objects)
* xmp.basicSchema.thumbnails = thumbnailArray;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._thumbnails = value;
this._setProperty('xap:Thumbnails', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfBasicSchema.prototype, "rating", {
/**
* Gets the rating.
*
* @returns {number[]} The rating.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the document properties
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access rating from basic schema
* let rating: number[] = xmpMetadata.basicSchema.rating;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (this._rating) {
return this._rating;
}
this._rating = this._getProperty('xap:Rating');
return this._rating;
},
/**
* Sets the rating.
*
* @param {number[]} value The rating 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 XMP metadata
* let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets rating
* xmp.basicSchema.rating = [5, 4, 3];
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._rating = value;
this._setProperty('xap:Rating', value);
},
enumerable: true,
configurable: true
});
return PdfBasicSchema;
}(PdfXmpSchema));
export { PdfBasicSchema };