通过Ooxml插入图像在Word Online中不起作用

时间:2019-02-27 14:25:08

标签: office-js

我正在尝试通过Ooxml在contentcontrol中插入图像,因为我想要与内联不同的textwrapping。在Word Desktop中,此方法工作正常,但在Word Online中,此方法失败。第一次似乎是插入图片,但是第二次它抛出了“不允许”错误。之后需要刷新文档。

这是要复制的脚本实验室代码:

$("#run").click(() => tryCatch(run));
$("#ooxml").click(() => tryCatch(getooxml));

let ooxml = '<?xml version="1.0" standalone="yes"?><?mso-application progid="Word.Document"?><pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"><pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512"><pkg:xmlData><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships></pkg:xmlData></pkg:part><pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="256"><pkg:xmlData><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.png"/></Relationships></pkg:xmlData></pkg:part><pkg:part pkg:name="/word/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"><pkg:xmlData><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"><w:body><w:drawing><wp:anchor distT="0" distB="0" distL="0" distR="0" simplePos="0" relativeHeight="251658240" behindDoc="0" locked="1" layoutInCell="1" allowOverlap="1"><wp:simplePos x="0" y="0" /><wp:positionH relativeFrom="character"><wp:align>left</wp:align></wp:positionH><wp:positionV relativeFrom="line"><wp:align>top</wp:align></wp:positionV><wp:extent cx="2628900" cy="1743075"/><wp:wrapSquare wrapText="bothSides"/><!--<wp:wrapNone/>--><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="3" name="Picture 3" descr="" /><wp:cNvGraphicFramePr><a:graphicFrameLocks noChangeAspect="1" noResize="0" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/></wp:cNvGraphicFramePr><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="2" name="Image.png"/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip r:embed="rId4"></a:blip><a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="2628900" cy="1743075"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic></wp:anchor></w:drawing></w:body></w:document></pkg:xmlData></pkg:part><pkg:part pkg:name="/word/media/image1.png" pkg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ErUhV2HNdexA8AXYnE8xHs31Hfdb+eTT2bXH+Pt+0w9RfEbpS7+53VycJd2ss0qM7HLs1l5LE9/0pAV8F/9HV82t/xTjl9l9x/j7dum529NpM+yi0nJutJ8Sd/0Q9QXpHXtVwb/ANFT9tm/54A/7EH+40/+f+Kc+nsv1AwRqL8gbb5/VE3srvI3vu+39k3UYemdA9nBR/uFHlsx/QZR4pdwiyqxKtHUjmtuR1JV1bB5SBnxEo/vUXdTdd0x17vslTjfs5v0lLXoXsCkG3mLFlXccw8Rvvt5+M2tsSUKRydayYMNXQSI50xEe0c9FS4DPyjSb0tmKJYD6bUSQWKKMdY8lmKKYww3khiKKYw+BHLCKKYxT1vEFTYDJ/ROd1ep5877npmKKLIZHNcY0y43/wD2c1Zoa+vKPXAiinBnSs6sLYGzTDG0wuKaGz4uQ4LAKxJJOB6mKKQjJxexfnYztPwW/qzDpjff9cN+5513rf1U55T9hiilnnnYixxLdfDNQdi4x3BsN9p6n1nons07PXFzc1vKi5UqpbJJ378gCKKNhk5ZFYuXyw2Oq1/F0Ny6cWNyoefUPyjJCYIrGB3nGTK3FeOvaeRByp346n1P6oopfW3f3IUtvsZqIB3eh3ktNoWtYIgGT3k93jFFGjFPY1s6rRcJo0w57PibxxkD0EPZx0fUT5n7oopX6dkR55AfhVtrAZO/cMATf0mn5FA+2KKMjMOok8RooRBjEYopgjYg3UEEMMgggg7gg9QR4RRTGPFe2XZoaO/CfwVuWqHeu/xJ8sjfwImIdMI8U4ptqTSISW5Xs0ozFFFF1MB//9k=</pkg:binaryData></pkg:part></pkg:package>';

async function run() {
  await Word.run(async (context) => {
    let controls = context.document.contentControls;
    controls.load("items");
    await context.sync();
    controls.items[0].insertOoxml(ooxml, "Replace");

    await context.sync();
  });
}

async function getooxml() {
  await Word.run(async (context) => {
    let controls = context.document.contentControls;
    controls.load("items, ooxml");
    await context.sync();
    let controlOoxml = controls.items[0].getOoxml();
    await context.sync();
    console.log(controlOoxml);

  });
}

/** Default helper for invoking an action and handling errors. */
async function tryCatch(callback) {
  try {
    await callback();
  } catch (error) {
    // Note: In a production add-in, you'd want to notify the user through your add-in's UI.
    console.error(error);
  }
}

0 个答案:

没有答案