Make media return a picture run instead

This commit is contained in:
Dolan
2019-06-23 22:36:01 +01:00
parent 427dc86915
commit dfe986331d
6 changed files with 31 additions and 15 deletions

View File

@ -1,7 +1,7 @@
// Add image to table cell
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Media, Packer, Table } from "../build";
import { Document, Media, Packer, Paragraph, Table } from "../build";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
@ -10,7 +10,7 @@ const table = new Table({
rows: 2,
columns: 2,
});
table.getCell(1, 1).addParagraph(image.Paragraph);
table.getCell(1, 1).addParagraph(new Paragraph(image));
doc.addTable(table);