docx
    Preparing search index...

    Class ImagePatch

    Replaces the image of a picture in a template, found by a placeholder in its alt text, such as {{logo}}, keeping its look: its size, position, text wrapping, border, shape, effects and link. Give it as a patch to patchDocument, with the placeholder's key.

    • The new image fills the picture, stretched to its size, unless a new transformation is given. Word's crop of the template's image is removed.
    • The placeholder is taken out of the alt text, unless new alt text is given.
    • The template's image is removed, unless something else, such as another picture, shows it.

    Put the placeholder in the picture's alt text in Word, in "Alt Text" or "Edit Alt Text". Every picture whose alt text holds it is patched, wherever it is: in the document, a table, a header, a footer or a note. A placeholder in the document's text is left as it is: use an ImageRun in a PatchType.PARAGRAPH patch for it.

    await patchDocument({
    outputType: "nodebuffer",
    data: template,
    patches: {
    logo: new ImagePatch({ type: "png", data: fs.readFileSync("logo.png") }),
    },
    });

    Hierarchy (View Summary)

    Index
    type: "drawing" = PatchType.DRAWING