Change method to createImageData

This commit is contained in:
Dolan
2018-08-01 23:32:31 +01:00
parent 4dd84ded54
commit 019ae24c7d
2 changed files with 4 additions and 10 deletions

View File

@ -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);

View File

@ -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);