Discussions

Expand all | Collapse all

How can I display and print photos in a report

  • 1.  How can I display and print photos in a report

    Posted 06-23-2017 14:57
    I am using the asset tracking template to keep track of furniture. I have added a field for images to upload a picture of the furniture. I need to print out a list of furniture with an image. Is this possible?


  • 2.  RE: How can I display and print photos in a report

    Posted 06-23-2017 18:51
    yup!

    with some code courtesy of Chris - (see his original here )


    [image] is your attachment field
    [name] is the title of your item ( chair, sofa, etc)

    i put it in a <div> that's 150px wide with a white background, so it always prints nice, 
    then put the NAME on the left and the IMAGE on the right, 50px tall.


     "<div style=\"background-color:#FFF; width:150px; height:52px; \">  " 
    &
    "<div style=\"float:left; width:60px; color:#636363; font-size:14px; font-family:Arial; \">" & [Name] & "</div>"
    &
    " <div style=\"float:right;\"><img style=\" height:50px;\" src=\"" &  URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0/" & [image]  & "\" ></div> " 
    &
    "</div>


    if you just want the image on the report, and they're all the right size, etc, then you just need the brilliant code from Chris to transform the image into a web url...

    URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0/" & [Image]



  • 3.  RE: How can I display and print photos in a report

    Silver
    Contributor
    Posted 09-05-2017 03:56
    Is there a way I can re size a photo in a form so that it is not too big? 


  • 4.  RE: How can I display and print photos in a report

    Posted 09-05-2017 12:37
    Try this format for a formula text field with html enabled and where the actual file attachment has been uploaded to field ID 282.,


    var text FileType = Right(ToText([file attachment2]),".");

    If(Contains("jpg, jepg, png",$FileType),
    "<img src=" & URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e282/v0' width='75' >")

    You can adjust the width to different values until you get the size you like.

    Alternatively you can use this to control the height.  The only difference is that we are specifying the height and not the width.  (you can also specify both, but then the image may get skewed in either the height or the width.

    var text FileType = Right(ToText([file attachment2]),".");

    If(Contains("jpg, jepg, png",$FileType),
    "<img src=" & URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e282/v0' height='75' >")


    The purpose of the IF is to display nothing if there is not file attachment or if the file attachment is not an image.  For example, this will not work for an Excel, PDF, or Word attachment.


  • 5.  RE: How can I display and print photos in a report

    Silver
    Contributor
    Posted 09-05-2017 21:29
    This is a great response Mark. Thanks. 


  • 6.  RE: How can I display and print photos in a report

    Silver
    Contributor
    Posted 09-05-2017 21:35
    I also picked up the following statement  which I added to a formula text and it worked. But I like the idea of testing for an attachment. Is the file attachment 2 in Var  is the name of the field? 


  • 7.  RE: How can I display and print photos in a report

    Posted 09-05-2017 21:41
    yes, the name of the field in my example was [file attachment 2]


  • 8.  RE: How can I display and print photos in a report

    Silver
    Contributor
    Posted 09-05-2017 21:43
    Thanks a lot. Works great.