Free Support Forum -

Resize image in Mail Merge Word Document Template with Ruby

Hello, I am a developer learning how to use your platform with Ruby to create inventory reports for our customers and am having trouble populating images into a table with the proper size. The images appear, and the methods return success on every attempt, but using the recommended syntax in our template IMAGE:PHOTO_URL:W=50 or IMAGE(50pt;50pt):LOGO_URL we notice that it’s not taking effect on the photos. The image size is being disregarded and blown up to a width that is beyond even the document width itself.

Here is the code I’m using for the PostDocumentExecuteMailMerge method provided by your API to create my JSON object:

def build_json(images, user)

    hash = {

        "LOGO_URL" => user.profile_photo_url,

        "Artist_Name" =>,

        "ACCOUNT_WEBSITE" => user.website_url,

        "Account_Name" =>,           

        "ReportData" => [ ]


    images.each do |img|

        table_data = {

            :PWf_Title =>, 

            :PWf_Image_URL => img.master_image.thumbnail_url,

            :PWf_Year => img.master_image.year,

            :PWf_Collection =>,

            :PWf_Paper_Type => img.paper_type,

            :PWf_Paper_Size => img.display_dimensions,

            :PWf_Frame_Size => img.display_frame_dimensions,

            :PWf_Framing => img.frame_type,

            :PWf_Edition_Size => img.out_of_edition


        hash["ReportData"] << table_data




def execute_mail_merge hashed_json

    filename = ASPOSE_TEMPLATE

    data = hashed_json.to_json

    request = filename, data, nil, :dest_file_name => nil

    @words_api.post_document_execute_mail_merge request


In my storage, I have a template that includes the table, and static content at the top. I attached it in this message as well. I suspect it has something to do with the way the table is formatted, however, I’m not familiar enough with word or mail-merging to know what the inception of this problem is.

Thank you for all your help!



Thanks for your inquiry. Please share your sample template and image here, you can zip the resource file and attach to the post… We will test the scenario at our end and will guide you accordingly.

We are sorry for your inconvenience.