[急]使用PastePTML合并文档时,wps接口报错导致待合并文档后图片无法正常加载

阅读次数 14

目前使用wps合并文档时出现合并文档后图片无法渲染的情况,具体情况在下方描述,希望能够尽快得到解决方案。 问题截图如下,此图片是待合并文档中的元素,选中蓝框中图片未正常渲染: <img src="https://solution-community.wps.cn/uploads/post/5drB3ECBQYq.png" alt="image.png"/> 对应实现代码如下:

	  // 导入图片的word文档
      this.insertInstance = WebOfficeSDK.init({
        officeType: 'w',
        appId: 'SX20240628SVYFAC',
        fileId,
        token: fileToken,
        mount: document.querySelector('#previewWpsHTML')
      })
      await this.insertInstance.ready()
      this.insertApp = this.insertInstance.Application
      setTimeout(async () => {
        const insertDocumentRange = await this.insertApp.ActiveDocument.GetDocumentRange()
        const insertHtmlData = await insertDocumentRange.GetHtmlData()
        const insertHTML = insertHtmlData.HTML
        await this.app.ActiveDocument.Range(
          this.selectBegin,
          this.selectEnd
        ).PasteHtml({ HTML: insertHTML })
      }, 3000)

这段代码中使用延时的方式等待插入文档的元素加载完成后再进行HTML内容的复制,打印结果证明HTML元素中存在可访问的图片路径,但后续图片渲染时报错,截图如下: <img src="https://solution-community.wps.cn/uploads/post/5drBJ1m1vvs.png" alt="image.png"/> 后根据排查,发现 https://o.wpsgo.com/api/v3/office/file/文档fileId/shapes 的接口请求出错,请求的参数和返回值链接打开的图片样式如下图: <img src="https://solution-community.wps.cn/uploads/post/5drCgQikLBs.png" alt="image.png"/>
<img src="https://solution-community.wps.cn/uploads/post/5drCqWHChAu.png" alt="image.png"/>
后续出现再次请求 https://o.wpsgo.com/api/v3/office/file/文档fileId/shapes 的接口报错,经排查是因为参数id为空,导致图片路径未携带id,返回值出现404错误,具体如下图:
<img src="https://solution-community.wps.cn/uploads/post/5drCB7NxVWq.png" alt="image.png"/>
当前初步判断是 https://o.wpsgo.com/api/v3/office/file/文档fileId/shapes 的接口在请求时出现了问题,导致图片无法正常渲染,请官方人员帮忙看看并给出解决方案。

0 Answers