// remove image variables in a DOCX template

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

const docxTemplate = fs.readFileSync("../../files/TemplateImages.docx");

const docx = new CreateDocx();
// load the template
docx.openTemplate(docxTemplate).then(docx => {
    // variables to be removed in the document
    const variablesDocument = ["IMAGE_1"];
    // remove template image variables in the document target
    docx.removeVariableImage(variablesDocument);

    // variables to be removed in the header target
    const variablesHeader = ["HEADERIMG"];
    // remove template variables in the header target
    docx.removeVariableImage(variablesHeader, "header");

    // save the DOCX
    docx.save().then(contents => {
        fs.writeFileSync("removeVariableImage_1.docx", Buffer.from(contents));
    });
});
