【问题标题】:Aspose: Image overflow the table when using with shape in imageFieldMergingAspose:在 imageFieldMerging 中使用形状时,图像溢出表格
【发布时间】:2020-09-18 14:54:01
【问题描述】:

当我尝试将图像直接插入 ImageFieldMergingArgs 时,它会使用以下代码正确显示在表格单元格中...

override fun imageFieldMerging(imageFieldMergingArgs: ImageFieldMergingArgs) {
        val fieldValue = imageFieldMergingArgs.fieldValue
        if (fieldValue is DataString) {
            val decodedImage = fieldValue.decode()
            imageFieldMergingArgs.imageStream = ByteArrayInputStream(decodedImage)
        }
    }

但是当我尝试在 MailMerge 中使用 Shape 插入图像时。然后它出现在桌子外面。我正在使用以下代码

override fun imageFieldMerging(imageFieldMergingArgs: ImageFieldMergingArgs) {
        val fieldValue = imageFieldMergingArgs.fieldValue
        if (fieldValue is DataString) {
            val shape = Shape(imageFieldMergingArgs.document, ShapeType.IMAGE)
            shape.wrapType = WrapType.SQUARE
            shape.aspectRatioLocked = false
            shape.anchorLocked = true
            shape.allowOverlap = false
            shape.width = imageFieldMergingArgs.imageWidth.value
            shape.height = imageFieldMergingArgs.imageHeight.value
            imageFieldMergingArgs.shape = shape
        }
    }

有什么方法可以使用 shape 到 imageFieldMergingArgs 将图像添加到表格单元格中。

谢谢

【问题讨论】:

    标签: aspose aspose.words


    【解决方案1】:

    当您指定 imageFieldMergingArgs.imageStream 时,将使用 WrapType.INLINE 插入形状。在第二个 sn-p 中,您指定 WrapType.SQUARE。这可能是不同之处。如果没有您的模板,很难准确地说出哪里出了问题。但我会尝试指定 WrapType.INLINE。我用一个简单的模板测试了你的代码 sn-ps 在这两种情况下,图像都在表格单元格内。

    【讨论】:

      猜你喜欢
      • 2021-04-10
      • 1970-01-01
      • 2018-10-10
      • 2018-06-26
      • 2015-11-27
      • 1970-01-01
      • 1970-01-01
      • 2021-07-06
      • 1970-01-01
      相关资源
      最近更新 更多