docxml
Version:
TypeScript (component) library for building and parsing a DOCX file
37 lines (36 loc) • 1.51 kB
TypeScript
import { ContentTypesXml } from '../../mod.js';
import { FileMime } from '../enums.js';
import { type File } from '../files/RelationshipsXml.js';
import { Archive } from './Archive.js';
declare type BinaryFileReader = () => Promise<Uint8Array>;
/**
* A utility class that represents a binary file inside the DOCX archive -- currently used for
* images.
*/
export declare class BinaryFile {
#private;
readonly location: string;
mime: FileMime;
protected constructor(location: string, reader: BinaryFileReader, mime: FileMime);
/**
* Get all XmlFile instances related to this one, including self. This helps the system
* serialize itself back to DOCX fullly. Probably not useful for consumers of the library.
*
* By default only returns the instance itself but no other related instances.
*/
getRelated(): File[];
get contentType(): Promise<FileMime>;
/**
* Let a file tell the system when it is effectively empty, so it can be omitted from the archive.
*/
isEmpty(): boolean;
static fromArchive(archive: Archive, contentTypes: ContentTypesXml, location: string): BinaryFile;
static fromDisk(diskLocation: string, location: string, mime: FileMime): BinaryFile;
static fromData(data: Uint8Array | Promise<Uint8Array>, location: string, mime: FileMime): BinaryFile;
toUint8Array(): Promise<Uint8Array>;
/**
* Add all related files to the given archive.
*/
addToArchive(archive: Archive): void;
}
export {};