pptx-embed-fonts
Version:
Embed fonts in pptx files
78 lines (69 loc) • 2.89 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _chunkXXANICLScjs = require('./chunk-XXANICLS.cjs');
// src/pptxgenjs.ts
var _jszip = require('jszip'); var _jszip2 = _interopRequireDefault(_jszip);
function withPPTXEmbedFonts(pptxgen) {
var _superExportPresentation, _a;
return _a = class extends pptxgen {
constructor() {
super();
_chunkXXANICLScjs.__privateAdd.call(void 0, this, _superExportPresentation);
this._pptxEmbedFonts = new (0, _chunkXXANICLScjs.index_default)();
_chunkXXANICLScjs.__privateSet.call(void 0, this, _superExportPresentation, this.exportPresentation);
this.exportPresentation = (options) => _chunkXXANICLScjs.__async.call(void 0, this, null, function* () {
const res = yield _chunkXXANICLScjs.__privateGet.call(void 0, this, _superExportPresentation).call(this, options);
const zip = yield new (0, _jszip2.default)().loadAsync(res);
yield this._pptxEmbedFonts.loadZip(zip);
yield this._pptxEmbedFonts.updateFiles();
if (options.outputType === "STREAM") {
return yield zip.generateAsync({
type: "nodebuffer",
compression: options.compression ? "DEFLATE" : "STORE"
});
} else if (options.outputType) {
return yield zip.generateAsync({
type: options.outputType
});
} else {
return yield zip.generateAsync({
type: "blob",
compression: options.compression ? "DEFLATE" : "STORE"
});
}
});
}
addFont(options) {
return _chunkXXANICLScjs.__async.call(void 0, this, null, function* () {
if (options.fontType === "ttf") {
yield this._pptxEmbedFonts.addFontFromTTF(
options.fontFace,
options.fontFile
);
} else if (options.fontType === "eot") {
yield this._pptxEmbedFonts.addFontFromEOT(
options.fontFace,
options.fontFile
);
} else if (options.fontType === "woff") {
yield this._pptxEmbedFonts.addFontFromWOFF(
options.fontFace,
options.fontFile
);
} else if (options.fontType === "otf") {
yield this._pptxEmbedFonts.addFontFromOTF(
options.fontFace,
options.fontFile
);
} else {
throw new Error(`Invalid font type ${options.fontType}`);
}
});
}
getFontInfo(fontFile) {
return this._pptxEmbedFonts.getFontInfo(fontFile);
}
}, _superExportPresentation = new WeakMap(), _a;
}
var pptxgenjs_default = withPPTXEmbedFonts;
exports.default = pptxgenjs_default; exports.withPPTXEmbedFonts = withPPTXEmbedFonts;
//# sourceMappingURL=pptxgenjs.cjs.map