Change method to createImageData
This commit is contained in:
@ -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);
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user