@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
254 lines (253 loc) • 8.5 kB
TypeScript
import { _PdfStream } from '../../core/base-stream';
import { PdfBasicSchema } from './pdf-basic-schema';
import { PdfDublinCoreSchema } from './pdf-dublin-core-schema';
import { PdfSchema } from './pdf-schema';
import { PdfPagedTextSchema } from './pdf-paged-text-schema';
import { PdfBasicJobTicketSchema } from './pdf-basic-job-ticket-schema';
import { PdfRightsManagementSchema } from './pdf-rights-management-schema';
import { PdfCustomSchema } from './pdf-custom-schema';
/**
* Represents the container for all XMP metadata in a PDF document.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Create XMP metadata
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmp: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Sets basic schema properties
* xmp.basicSchema.creatorTool = 'MyApp 1.0';
* xmp.basicSchema.createDate = new Date();
* // Sets Dublin Core properties
* xmp.dublinCoreSchema.title = {'en-US': 'My Document'};
* xmp.dublinCoreSchema.creator = ['John Doe'];
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare class PdfXmpMetadata {
private _xmlWriter;
private _buffer;
/**
* Registry of namespace prefixes to avoid duplicate declarations.
*
* @private
*/
_namespaceRegistry: Set<string>;
/**
* Custom schemas instance on the XMP metadata.
*
* @private
*/
_customSchemas: PdfCustomSchema[];
/**
* Internal custom schemas instance on the XMP metadata.
*
* @private
*/
_customSchema: PdfCustomSchema;
private _dublinCoreSchema;
private _basicSchema;
private _pdfSchema;
private _pagedTextSchema;
private _basicJobTicketSchema;
private _rightsManagementSchema;
/**
* Internal flag checks the metadata is updated or not.
*
* @private
*/
_isUpdated: boolean;
/**
* The stream contains the serialized XMP metadata packet
*
* @private
*/
_xmpStream: _PdfStream;
/**
* The stream contains the serialized XMP metadata packet.
*```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Create XMP metadata
* let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false);
* // Gets XMP metadata
* let xmp: PdfXmpMetadata = documentProperties.xmpMetadata;
* // Access the xmp stream data
* let stream = xmp.xmpStream;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
xmpStream: Uint8Array;
/**
* Initializes a new `PdfXmpMetadata` instance.
*
* @private
*/
constructor();
/**
* Gets or creates the Dublin Core metadata schema.
*
* @public
* @returns {PdfDublinCoreSchema} The Dublin Core 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 the xmp metadata
* let xmp = documentProperties.xmpMetadata;
* // Access Dublin Core schema
* xmp.dublinCoreSchema.creator = ['John Doe'];
* ```
*/
readonly dublinCoreSchema: PdfDublinCoreSchema;
/**
* Gets or creates the Basic XMP schema.
*
* @public
* @returns {PdfBasicSchema} 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 the xmp metadata
* let xmp = documentProperties.xmpMetadata;
* // Access Basic schema
* xmp.basicSchema.creatorTool = 'MyApp 1.0';
* ```
*/
readonly basicSchema: PdfBasicSchema;
/**
* Gets or creates the PDF-specific metadata schema.
*
* @public
* @returns {PdfSchema} The PDF 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 the xmp metadata
* let xmp = documentProperties.xmpMetadata;
* // Access PDF schema
* xmp.pdfSchema.keywords = 'test, document';
* ```
*/
readonly pdfSchema: PdfSchema;
/**
* Gets or creates the Paged-Text metadata schema.
*
* @public
* @returns {PdfPagedTextSchema} The Paged-Text 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 the xmp metadata
* let xmp = documentProperties.xmpMetadata;
* // Access Paged-Text schema
* xmp.pagedTextSchema.pageCount = 10;
* ```
*/
readonly pagedTextSchema: PdfPagedTextSchema;
/**
* Gets or creates the Basic Job Ticket schema.
*
* @public
* @returns {PdfBasicJobTicketSchema} The Basic Job Ticket 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 the xmp metadata
* let xmp = documentProperties.xmpMetadata;
* // Access Basic Job Ticket schema
* xmp.basicJobTicketSchema.jobRef = ['Job001'];
* ```
*/
readonly basicJobTicketSchema: PdfBasicJobTicketSchema;
/**
* Gets or creates the Rights Management schema.
*
* @public
* @returns {PdfRightsManagementSchema} The Rights Management schema.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
// 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;
* // Access Rights Management schema
* xmp.rightsManagementSchema.isMarked = true;
* ```
*/
readonly rightsManagementSchema: PdfRightsManagementSchema;
/**
* Gets the internal custom schema.
*
* @private
* @returns {PdfCustomSchema} The internal custom schema.
*/
readonly customSchema: PdfCustomSchema;
/**
* Builds the complete XMP packet as a byte array.
* Generates the XML structure with all active schemas and returns the serialized bytes.
*
* @private
* @returns {Uint8Array} The XMP packet bytes.
*/
_build(): Uint8Array;
/**
* Writes all active schemas to the XML writer.
* Iterates schemas in deterministic order and delegates to _writeSchema.
*
* @private
* @param {_XmlWriter} writer The XML writer instance.
* @returns {void}
*/
private _writeSchemas;
/**
* Writes a single schema's RDF Description block.
* Handles namespace registration and delegates property serialization to the schema.
*
* @private
* @param {_XmlWriter} writer The XML writer instance.
* @param {PdfXmpSchema} schema The schema to write.
* @returns {void}
*/
private _writeSchema;
/**
* Serializes the XMP metadata to a PDF stream object.
* Calls _build() and creates an uncompressed PdfStream with appropriate dictionary entries.
*
* @private
* @returns {void}
*/
_serializeToStream(): void;
/**
* Destroys the metadata object and releases all resources.
* Clears all schema references, registry, and buffers.
*
* @private
* @returns {void}
*/
_destroy(): void;
}