@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
337 lines (336 loc) • 13.3 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 metadata related to document rights and permissions.
* ```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 xmp: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets rights information
* xmp.rightsManagementSchema.isMarked = true;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
var PdfRightsManagementSchema = /** @class */ (function (_super) {
__extends(PdfRightsManagementSchema, _super);
/**
* Initializes a new `PdfRightsManagementSchema` instance.
*
* @private
* @param {PdfXmpMetadata} xmp Optional parent PdfXmpMetadata reference.
*/
function PdfRightsManagementSchema(xmp) {
var _this = _super.call(this, xmp) || this;
_this._prefix = 'xmpRights';
_this._name = 'RightsManagement';
return _this;
}
Object.defineProperty(PdfRightsManagementSchema.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 rights management schema from the XMP metadata
* let rightSchema: PdfRightsManagementSchema = documentProperties.xmpMetadata.rightsManagementSchema;
* // Gets the schema type
* let schemaType: PdfXmpSchemaType = rightSchema.schemaType;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
return PdfXmpSchemaType.rightsManagement;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfRightsManagementSchema.prototype, "certificateUrl", {
/**
* Gets the certificate URL.
*
* @returns {string} The certificate 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 the xmp metadata
* let xmpMetadata = documentProperties.xmpMetadata;
* // Access certificate URL from rights management schema
* let certificate: string = xmpMetadata.rightsManagementSchema.certificateUrl ;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._certificate) {
this._certificate = this._getProperty('xmpRights:Certificate');
}
return this._certificate;
},
/**
* Sets the certificate URL.
*
* @param {string} value The certificate URL 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 certificate URL
* xmp.rightsManagementSchema.certificateUrl = 'https://example.com/certificate';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._certificate = value;
this._setProperty('xmpRights:Certificate', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfRightsManagementSchema.prototype, "webStatement", {
/**
* Gets the web statement URL.
*
* @returns {string} The web statement 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 the xmp metadata
* let xmpMetadata = documentProperties.xmpMetadata;
* // Access web statement URL from rights management schema
* let webStatement: string = xmpMetadata.rightsManagementSchema.webStatement;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._webStatement) {
this._webStatement = this._getProperty('xmpRights:WebStatement');
}
return this._webStatement;
},
/**
* Sets the web statement URL.
*
* @param {string} value The web statement URL 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 web statement URL
* xmp.rightsManagementSchema.webStatement = 'https://example.com/rights';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._webStatement = value;
this._setProperty('xmpRights:WebStatement', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfRightsManagementSchema.prototype, "isMarked", {
/**
* Gets whether the document is rights-marked.
*
* @returns {boolean} The rights-marked status.
*
* ```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 marked status from rights management schema
* let isMarked: boolean = xmpMetadata.rightsManagementSchema.isMarked;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (typeof this._isMarked !== 'undefined') {
return this._isMarked;
}
var stored = this._getProperty('xmpRights:Marked'); // eslint-disable-line
if (typeof stored === 'string') {
return stored === 'True';
}
return false;
},
/**
* Sets whether the document is rights-marked.
*
* @param {boolean} value The rights-marked status 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 rights-marked status
* xmp.rightsManagementSchema.isMarked = true;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._isMarked = value;
this._setProperty('xmpRights:Marked', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfRightsManagementSchema.prototype, "owners", {
/**
* Gets the list of owners(rdf:Bag).
*
* @returns {string[]} The list of owners.
*
* ```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 owners from rights management schema
* let owners: string[] = xmpMetadata.rightsManagementSchema.owners;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
return this._owner || this._getProperty('xmpRights:Owner') || [];
},
/**
* Sets the list of owners (rdf:Bag).
*
* @param {string[]} value The list of owners 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 the list of owners
* xmp.rightsManagementSchema.owners = ['Owner 1', 'Owner 2'];
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._owner = value;
this._setProperty('xmpRights:Owner', value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(PdfRightsManagementSchema.prototype, "usageTerms", {
/**
* Gets the usage terms language (rdf:Alt).
*
* @returns {PdfXmpLangArray} The usage terms.
*
* ```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 usage terms from rights management schema
* let usageTerms: PdfXmpLangArray = xmpMetadata.rightsManagementSchema.usageTerms;
* // Destroy the document
* document.destroy();
* ```
*/
get: function () {
if (!this._usageTerms) {
this._usageTerms = this._getProperty('xmpRights:UsageTerms');
}
return this._usageTerms;
},
/**
* Sets the usage terms language (rdf:Alt).
*
* @param {PdfXmpLangArray} value The usage terms 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 usage terms
* xmp.rightsManagementSchema.usageTerms = { 'en': 'For internal use only', 'fr': 'Pour usage interne uniquement' } as PdfXmpLangArray;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
set: function (value) {
this._usageTerms = value;
this._setProperty('xmpRights:UsageTerms', value);
},
enumerable: true,
configurable: true
});
return PdfRightsManagementSchema;
}(PdfXmpSchema));
export { PdfRightsManagementSchema };