node-unrtf
Version:
Asynchronous Node.js wrapper for the UnRTF RTF conversion program
103 lines (102 loc) • 3.17 kB
TypeScript
export default UnRTF;
export type OptionDetails = {
/**
* The argument to pass to the binary.
*/
arg: string;
/**
* The type of the option.
*/
type: ("boolean" | "number" | "string");
/**
* The minimum version of the binary that supports this option.
*/
minVersion: string;
/**
* The maximum version of the binary that supports this option (optional).
*/
maxVersion?: string | undefined;
};
export type UnRTFAcceptedOptions = Record<string, OptionDetails>;
export type UnRTFOptions = {
/**
* Disable the automatic storing of embedded
* pictures to the current working directory.
*/
noPictures?: boolean | undefined;
/**
* Disable charset conversion (only works for 8-bit charsets)
* (UnRTF v0.20.5 or later only).
*/
noRemap?: boolean | undefined;
/**
* Generate HTML output.
*/
outputHtml?: boolean | undefined;
/**
* Generate LaTeX output.
*/
outputLatex?: boolean | undefined;
/**
* Generate PostScript (PS) output (UnRTF v0.19.4 or earlier only).
*/
outputPs?: boolean | undefined;
/**
* Generate RTF output. (UnRTF v0.21.3 or later only).
*/
outputRtf?: boolean | undefined;
/**
* Generate ASCII text output.
*/
outputText?: boolean | undefined;
/**
* Generate text output with VT100 escape codes.
*/
outputVt?: boolean | undefined;
/**
* Generate WPML output (UnRTF v0.19.4 or earlier only).
*/
outputWpml?: boolean | undefined;
/**
* Print copyright and version info.
*/
printVersionInfo?: boolean | undefined;
/**
* Do not print any leading comments in output (UnRTF v0.21.3 or later only).
*/
quiet?: boolean | undefined;
};
export class UnRTF {
/**
* @param {string} [binPath] - Path of UnRTF binary.
* If not provided, the constructor will attempt to find the binary
* in the PATH environment variable.
*
* For `win32`, a binary is bundled with the package and will be used
* if a local installation is not found.
*/
constructor(binPath?: string);
/** @type {UnRTFAcceptedOptions} */
unrtfAcceptedOptions: UnRTFAcceptedOptions;
/**
* @description Returns the path of the UnRTF binary.
* @returns {string} Path of UnRTF binary.
*/
get path(): string;
/**
* @description Returns the version of the UnRTF binary.
* @returns {string} Version of UnRTF binary.
*/
get version(): string;
/**
* @author Frazer Smith
* @description Converts an RTF file to HTML/LaTeX/RTF/TXT.
* Defaults to HTML output if no `output*` options are provided.
* UnRTF will use the directory of the original file to store embedded pictures.
* @param {string} file - Filepath of the RTF file to read.
* @param {UnRTFOptions} [options] - Options to pass to UnRTF binary.
* @returns {Promise<string>} A promise that resolves with a stdout string, or rejects with an `Error` object.
*/
convert(file: string, options?: UnRTFOptions): Promise<string>;
#private;
}