From b0fe1d8987e6777f587c6d5ff7eb4820f301fa6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Fernandez?= Date: Mon, 15 Sep 2025 17:59:06 +0200 Subject: [PATCH] Add a draw image and a draw frame into odt file --- .../odf/templating/fillOdtElementTemplate.js | 18 ++++++++++++++++++ scripts/odf/templating/fillOdtTemplate.js | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/odf/templating/fillOdtElementTemplate.js b/scripts/odf/templating/fillOdtElementTemplate.js index 5871450..b7bb92d 100644 --- a/scripts/odf/templating/fillOdtElementTemplate.js +++ b/scripts/odf/templating/fillOdtElementTemplate.js @@ -801,6 +801,24 @@ export default function fillOdtElementTemplate(rootElements, compartment, addIma console.log({imageMarker}, "dans le if imageMarker") if (imageMarker.odfjsImage) { const href = addImageToOdtFile(imageMarker.odfjsImage) + + const newImageNode = currentNode.ownerDocument?.createElement("draw:image") + newImageNode.setAttribute("xlink:href", href) + newImageNode.setAttribute("xlink:type", "simple") + newImageNode.setAttribute("xlink:show", "embed") + newImageNode.setAttribute("xlink:actuate", "onLoad") + newImageNode.setAttribute("draw:mime-type", imageMarker.odfjsImage.mediaType) + + const newFrameNode = currentNode.ownerDocument?.createElement('draw:frame') + newFrameNode.setAttribute("text:anchor-type", "char") + newFrameNode.setAttribute("svg:width", "7.28cm") + newFrameNode.setAttribute("svg:height", "10.239cm") + newFrameNode.setAttribute("draw:z-index", "0") + newFrameNode.appendChild(newImageNode) + + currentNode.parentNode?.replaceChild(newFrameNode, currentNode) + + // TODO : // - Rajouter un fichier image dans le odt avec le ArrayBuffer comme contenu (ou autre type) // - puis remplacer le texte par peut-être