Embed Images/Signatures in Word/Excel/PowerPoint

*Note: This article is for embedding images that are sent over in the Merge Data.  Not embedding signatures from e-signature services like DocuSign, AdobeSign, HelloSign, etc.

*Also Note: All images merged over must be publically accessible so we can download it to our system.

Due to the way Microsoft Office files are designed, embedding dynamic images in an Office document is not as simple as when you are using our Builder.  But, it is still possible with a little bit of work.  Below is a quick tutorial on how you can embed a dynamic image (signature, uploaded picture, etc) into your Word DOCX documents.  For this example, we will be embedding a Formstack signature in our DOCX.

First thing you will need to do is embed an image in your document as placeholder for where you want the final image to go.  The size that you make this image placeholder will be the size that the final image will be.  It is important to note that you must use a placeholder with the same file format (JPEG or PNG) as the final image.

If you do not have an image placeholder to use, we have built an image generator that you can use.  Here is an example URL:

http://www.webmerge.me/images/image.php?width=300&height=100&type=png

If you go to that URL, it will load an image.  Simply right-click the image and copy the image, then paste that image into your word document.  In the URL, you will notice there is width and height setting so you can control the size of the image. 

Also, the type parameter (possible values: png or jpeg) controls the type of the image.  Go ahead and change those parameters to create a customized image.


The next step is the setup the variable placeholder for your image.  You can put this placeholder anywhere in your document – it is simply used to map the image URL to the image element in your document.  For the most part, it’s the same format as other variables, but we will add a little more info. Below is an example variable placeholder for the image:

{$MyImage|image:1:png}

In the above example, the variable name is “MyImage”, then the “|” indicates options after.  Each image in a DOCX is stored using a numerical identifier, so the “1” in the image indicates that identifier. 

Once you have that in place, you’re all set!

 

**If you are inserting more than 1 image in your document, you'll want to make sure you use different images as the placeholders because Word will treat them as the same image.  If you are using our image generator, simply add a pixel to the width or height of the image and that will do the trick!

 

Inserting a dynamic image (Word and PPT only)

If you are looping through a list of images, using the placeholder method above will produce the same image over and over again.  To fix this, we've created a new way to add an image to your document using the following tag:

{$image|insert_image:width:height:max_width(optional):max_height(optional)}

Here's a real example:

{$image|insert_image:300:100}

To break down this tag, $image is the merge field, 300 is the width, and 100 is the height (you can change these to create the correct size image).

You would place this tag in the spot that you want your image inserted and it will be replaced with your image when the document is merged.

If you wanted to automatically size the height to keep proportions, you can use a "0" for the height like this:

{$image|insert_image:300:0}

If you'd like to set a maximum height to your image, you would use a tag like this:

{$image|insert_image:300:0:0:200}

Was this article helpful?
7 out of 16 found this helpful

Comments

49 comments
  • Hi Jeremy,

    I am trying to attach looped images into a word doc using a URL built from attributes submitted from Survey123 response.

    The URL is https://services.arcgis.com/cJ9YHowT8TU7DUyn/ArcGIS/rest/services/service_44e4d3fe05b043aeb98d4b60a4f4691d/FeatureServer/1/$_image.attachments.addResults.objectId/attachments/$_image.addResults.objectId?token=$portalInfo.token

    The items that are unique to each attached are the $_image.attachments.addResults.objectId, $_image.addResults.objectId, and $portalInfo.token

    What would be the syntax for referencing and attaching in a image from a URL that is not in but built from the Survey123 response nested in a foreach loop?

    Thanks,

    0
  • Thank Jeremy,

    Is there a way for the foreach loop to search two arrays simultaneously? I need to pull two different Ids at the same time to build the URL string without nesting the foreach loops.

    Thanks,

    0
  • Hi Bill,

    Please submit a ticket to our support team and we can help you with your specific question. The short answer is yes you can grab data from multiple arrays, but it all depends on the format of your arrays.

    Thanks!

    0
  • Hi Jeremy,

    I have a ppt document and depending on people's results to a test, I want to display an image with 1 star, one with 2 stars, or one with 3 stars.
    So my question is: Is it possible to dynamically merge images conditionally?
    If yes, do I do that through webmerge or through my excel sheet that I use as my results calculator?
    Thank you so much!

    0
  • Hi Anthony,

    The easiest route is to upload your 3 images to a server somewhere (or google drive / dropbox) then send over the URL to the image that you want to display in your document.

    If that doesn't work, you could send over the score in your merge data, then use the Field Map (https://support.webmerge.me/hc/en-us/articles/206526086-Field-Map) to set the value of your merge field based on logic like this:

    {if $score == 1}URL{elseif $score == 2}URL{elseif $score == 3}URL{/if}

    0
  • Hey Jeremy,
    Can we use a base64 encoded image to merge an image to a document or does it need to be a URL?
    Thanks,
    Steve

    0
  • Hi Steve,

    Yes, you can use base64 but make sure to include the content type at the beginning like:

    data:image/png;base64,[BASE64 HERE]

    0
  • Hello Johnathan,

    I am pulling data from 2 ZOHO forms into a Excel created pdf. I am able to merge all of the information except for the 2 signatures from the Physician and patient. how can I grab those two field in excel. the above solution with word doesn't work for Excel

    0
  • Hi Chris,

    In Excel you have to use the "placeholder" method (the first example at the top of this help article) to embed the image. The "insert_image" does not work in Excel. Can you please confirm that you're using 2 unique image placeholders?

    Also, can you turn on Debug Mode to make sure we are receiving valid URLs to the images?

    0
  • Hey Jeremy,

    I fixed the URL issue, ZOHO Forms direct integration works there, zapier does not bring the url for the signature. I thought I had the placeholder correct. is it possible to set up a call?

    0
  • Jeremy,
    Thanks for the quick response! Is there a file size limit when transferring a base64 encoded image?
    - Steve

    0
  • Hi Chris,

    Please reach out to our support team and request a call from Sales and they'll get you connected for a quick call!

    0
  • Hi Steve,

    We have a 100MB limit for data being sent to our system, so anything below that!

    Thanks,

    0
  • Hi Jeremy -
    i'm using this for my Excel document... When the placeholder isn't utilized in a merge, a "200px X 200px" still shows up in my merged document. Is there a way to remove the "200px X 200px" from the picture placeholder? thanks!

    0
  • Hi Jonathan,

    Unfortunately, there isn't a way to remove the placeholder in an Excel document due to formatting restrictions of an Excel document. Sorry! I would suggest setting up a 2nd template without the image, then use Data Routing to pick which template to use based on if there's an image value or not

    0
  • Jeremy - thanks for the quick response!

    0
  • Jeremy -
    If it does anyone else any good, I did find a workaround and was able to achieve what I wanted. 1) I used my Windows Snipping Tool to make a picture of a blank screen. 2) Gave that picture a unique name. 3) Inserted the picture into my Excel document and removed the border. 4) Repeated this until I have all the possible picture locations covered. Since the pictures i'm inserting are the same color as the Excel workbook background, they are invisible. 5) Upload the *.xlsx to WebMerge and make sure it recognizes all the pictures I just added. 6) write my Merge fields in my Excel workbook for the pictures i just added (syntax: {$yourarrayname.yourpictureserial#.picture.url|image:yourplaceholder#:png}) 7) re-upload the *xlsx. 8) Any placeholder pictures that don't get filled stay invisible because they''re the same color as the background.

    0
  • Jonathan-
    Thank you very much for sharing this! I will set this tip aside to help future customers! Please reach out if you have any more questions!

    0

Please sign in to leave a comment.