diff --git a/demo/demo18.js b/demo/demo18.js index b850e9fe4d..e7f577a29a 100644 --- a/demo/demo18.js +++ b/demo/demo18.js @@ -8,8 +8,8 @@ const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEU // var buff = fs.readFileSync("./demo/images/image1.jpeg"); // console.log(buff); -// const image = doc.createImageData("image1.jpeg", buff); -const image = doc.createImageData("image.png", Buffer.from(imageBase64Data, 'base64'), 100, 100); +// const image = doc.createImageFromBuffer("image1.jpeg", buff); +const image = doc.createImageFromBuffer("image.png", Buffer.from(imageBase64Data, 'base64'), 100, 100); doc.Document.createDrawing(image); var exporter = new docx.LocalPacker(doc); diff --git a/src/file/file.ts b/src/file/file.ts index 866ddd1480..667b09e325 100644 --- a/src/file/file.ts +++ b/src/file/file.ts @@ -135,8 +135,8 @@ export class File { return this.document.createDrawing(mediaData); } - public createImageData(imageName: string, data: Buffer, width?: number, height?: number): IMediaData { - const mediaData = this.media.addMediaWithData(imageName, data, this.nextId++, width, height); + public createImageFromBuffer(key: string, data: Buffer, width?: number, height?: number): IMediaData { + const mediaData = this.media.addMediaWithData(key, data, this.nextId++, width, height); this.docRelationships.createRelationship( mediaData.referenceId, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", @@ -179,9 +179,6 @@ export class File { this.footNotes.createFootNote(paragraph); } - /** - * Creates new header. - */ public createHeader(): HeaderWrapper { const header = new HeaderWrapper(this.media, this.nextId++); this.headerWrapper.push(header); @@ -194,9 +191,6 @@ export class File { return header; } - /** - * Creates new footer. - */ public createFooter(): FooterWrapper { const footer = new FooterWrapper(this.media, this.nextId++); this.footerWrapper.push(footer);