Skip to main content
Participating Frequently
August 11, 2020
Question

CF10 display output as an image

  • August 11, 2020
  • 5 replies
  • 424 views

I'm not sure if it is possible, but is there a way to wrap a bunch of various outputs from coldfusion as a single image?  I am building an email signature creator and after the user finishes entering their name, title, campus location, etc... I need them to be able to copy the output and paste it in Outlook.  The issue is that the column divs are ignored by outlook so instead of the paste being horizontal, everything ends up vertical.  If I take a screen shot and paste that into Outlook it works perfectly.  So that is why I want to have the output be an image that can be copy/pasted.  Anyone have a thought on how to accomplish this?

    This topic has been closed for replies.

    5 replies

    Participant
    August 17, 2020

    I didn't see this mentioned, but have you considered the built in image functions available I think since CF8.  Define your image size, use imageDrawText to output the text input fields, and output to the screen.  Here is the help info

     

    https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-h-im/imagedrawtext.html

    https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-by-category/image-functions.html

     

    hope that helps

     

    BKBK
    Community Expert
    Community Expert
    August 12, 2020

    dannym22968722"...I want to have the output be an image that can be copy/pasted.  Anyone have a thought on how to accomplish this?"

     

    This tells me you want to have 2 things:

    1) the output of a CFM page as the user would see it in the browser.

    2) that output rendered as an image or a PDF.

     

    If so, then I have a thought on how to accomplish it. I have a tool in mind: wkhtmltopdf.

     

    Don't let the name confuse you. Wkhtmltopdf can do either, that is, convert to image or PDF. I shall give you an example that converts to image. (You will find an example of wkhtmltopdf conversion elsewhere in this forum)

     

    Steps :

    1) Download and install the "Installer (Vista or later) 64-bit" (assuming you're on 64-bit Windows). Accept the installation default.

    2) Verify that the key executables, wkhtmltoimage.exe and wkhtmltopdf.exe, are present in C:\Program Files\wkhtmltopdf\bin.

     

    That's it. You're ready to go. 

     

    <!---
    wkhtmltoimage Usage
    To see the available options: 
    Open the CMD as administrator. Navigate in DOS Command-line to C:\Program Files\wkhtmltopdf\bin. Then enter the command: wkhtmltoimage -H
    
    To download the available options: 
    Navigate in DOS Command-line to C:\Program Files\wkhtmltopdf\bin. Then enter the command: wkhtmltoimage -H > wkhtmltoimage_options.txt
     --->
    
    <!--- 
    Set up all wkhtmltoimage's options. 
    For example, use the following to obtain an image of the page test.cfm, cropped to height 600px and width 800px.
    The image file is saved in the current directory.
    --->
    <cfset wkHTMLToImageOptions = "--crop-h 600 --crop-w 800">
    <cfexecute  name="C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe" 
    	arguments="#wkHTMLToPDFOptions# http://127.0.0.1:8500/workspace/CF_Project/test.cfm #expandpath('testImg.png')#"  timeout="10">
    </cfexecute>
    BKBK
    Community Expert
    Community Expert
    August 12, 2020

    More tips:

    1) It might help to enclose within <pre></pre> tags the output to be "photographed".

    2) Experiment (in wkhtmltoimage) with various --crop-h, --crop-w values till you get the right dimensions.

    WolfShade
    Legend
    August 11, 2020

    AH!  Okay.. understood.  Still, if the outgoing email is formatted HTML, the signature _should_ also be formatted as HTML, and if the formatting isn't sticking in the sig editor.. well.. not sure.. I wonder if the file that contains the signature can be edited outside of Outlook.

     

    After some quick Googling, I found the following that I hope might help.

    https://www.extendoffice.com/documents/outlook/3941-open-edit-outlook-signature-in-word.html

     

    Apparently you can edit an Outlook sig block in WORD.

     

    HTH,

     

    ^ _ ^

    Participating Frequently
    August 11, 2020

    I feel like we are getting down a rabbit hole and away from my original question.  This is for a bunch of teachers who honestly believe that things that are typed are "magic" so a multi-step process isn't exactly ideal.

    WolfShade
    Legend
    August 11, 2020

    Okay, so the curious thing, for me, is that Outlook is ignoring the formatting divs.  Have you disabled HTML for outgoing emails?  This seems the most likely.  I've copied/pasted into Outlook, before, and it appears as copied.  Or are you using an older version of Outlook that might not support some of the more modern code?

     

    Just food for thought.

     

    V/r,

     

    ^ _ ^

    Participating Frequently
    August 11, 2020

    This is in the signature block in the settings, not just in an email in general. If I manually paste it in a message it works fine, but setting as a default signature the formatting is ignored. 

    WolfShade
    Legend
    August 11, 2020

    Would converting the output to a PDF work?

     

    V/r,

     

    ^ _ ^

    Participating Frequently
    August 11, 2020

    I tried it and the pdf still does the copy/pasting as individual sections instead of a single element.  So same issue.