// add inline images as WordFragment contents

import { CreateDocx, OptionsImage, WordFragment } from "../../../build";
import * as fs from "fs";

const docx = new CreateDocx();

const fileJpg = fs.readFileSync("../../files/image.jpg");
const filePng = fs.readFileSync("../../files/image.png");

const wordFragmentImageA = new WordFragment();
const imageJpg: OptionsImage = {
    image: fileJpg,
};
wordFragmentImageA.addImage(imageJpg);

const wordFragmentImageB = new WordFragment();
const imagePng: OptionsImage = {
    image: filePng,
};
wordFragmentImageB.addImage(imagePng);

// add the WordFragments as inline contents in the same paragraph
docx.addText([wordFragmentImageA, wordFragmentImageB]);

docx.save().then(contents => {
    fs.writeFileSync("addImage_4.docx", Buffer.from(contents));
});
