MergeFieldImageDimension constructor

MergeFieldImageDimension(value)

Creates an image dimension instance with the given value in points.

def __init__(self, value: float):
    ...
ParameterTypeDescription
valuefloatThe value.

Remarks

You should use a negative value to indicate that the original value of the corresponding image dimension should be applied.

MergeFieldImageDimension(value, unit)

Creates an image dimension instance with the given value and the given unit.

def __init__(self, value: float, unit: aspose.words.fields.MergeFieldImageDimensionUnit):
    ...
ParameterTypeDescription
valuefloatThe value.
unitMergeFieldImageDimensionUnitThe unit.

Remarks

You should use a negative value to indicate that the original value of the corresponding image dimension should be applied.

Examples

Shows how to set the dimensions of images as MERGEFIELDS accepts them during a mail merge (MergedImageResizer).

class MergedImageResizer(aw.mailmerging.IFieldMergingCallback):

    def __init__(self, image_width, image_height, unit):
        self.m_image_width = image_width
        self.m_image_height = image_height
        self.m_unit = unit

    def field_merging(self, e):
        raise Exception()

    def image_field_merging(self, args):
        args.image_file_name = str(args.field_value)
        args.image_width = aw.fields.MergeFieldImageDimension(value=self.m_image_width, unit=self.m_unit)
        args.image_height = aw.fields.MergeFieldImageDimension(value=self.m_image_height, unit=self.m_unit)
        self.assertEqual(self.m_image_width, args.image_width.value)
        self.assertEqual(self.m_unit, args.image_width.unit)
        self.assertEqual(self.m_image_height, args.image_height.value)
        self.assertEqual(self.m_unit, args.image_height.unit)
        self.assertIsNone(args.shape)

See Also