Aspose:在 imageFieldMerging 中使用 with shape 时图像溢出 table
Aspose: Image overflow the table when using with shape in imageFieldMerging
当我尝试将图像直接插入 ImageFieldMergingArgs 时,它使用以下代码在 table 单元格中正确显示...
override fun imageFieldMerging(imageFieldMergingArgs: ImageFieldMergingArgs) {
val fieldValue = imageFieldMergingArgs.fieldValue
if (fieldValue is DataString) {
val decodedImage = fieldValue.decode()
imageFieldMergingArgs.imageStream = ByteArrayInputStream(decodedImage)
}
}
但是当我尝试在 MailMerge 中使用 Shape 插入图像时。然后它出现在 table 之外。我正在使用以下代码
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 to imageFieldMergingArgs 将图像添加到 table 单元格中。
谢谢
当您指定 imageFieldMergingArgs.imageStream 时,将使用 WrapType.INLINE 插入形状。在您的第二个片段中,您指定 WrapType.SQUARE。这可能就是不同之处。如果没有您的模板,很难准确地说出问题所在。但我会尝试指定 WrapType.INLINE。我用一个简单的模板在我这边测试了你的代码片段,在这两种情况下图像都在 table 单元格内。
当我尝试将图像直接插入 ImageFieldMergingArgs 时,它使用以下代码在 table 单元格中正确显示...
override fun imageFieldMerging(imageFieldMergingArgs: ImageFieldMergingArgs) {
val fieldValue = imageFieldMergingArgs.fieldValue
if (fieldValue is DataString) {
val decodedImage = fieldValue.decode()
imageFieldMergingArgs.imageStream = ByteArrayInputStream(decodedImage)
}
}
但是当我尝试在 MailMerge 中使用 Shape 插入图像时。然后它出现在 table 之外。我正在使用以下代码
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 to imageFieldMergingArgs 将图像添加到 table 单元格中。
谢谢
当您指定 imageFieldMergingArgs.imageStream 时,将使用 WrapType.INLINE 插入形状。在您的第二个片段中,您指定 WrapType.SQUARE。这可能就是不同之处。如果没有您的模板,很难准确地说出问题所在。但我会尝试指定 WrapType.INLINE。我用一个简单的模板在我这边测试了你的代码片段,在这两种情况下图像都在 table 单元格内。