Skip to main content

Reports with Photos and Attachments

Comments

25 comments

  • John Nerge

    How are your photos stored? I have a property report that pulls a photo of the property stored in SQL Server via a data link.

    0
  • Permanently deleted user

    We've had photos as files with filenames in fields using the following code and had situations where the photo is repeated between features.

    But we're moving away from files and more towards attachments with ArcGIS Mobile handling attachments.

     

        string pictureUrl ="http://server/" + rpt.Fields["PHOTOLINK"].Value;

     

      

     

        //Setting up the image to retrieve webrequest

     

        System.Drawing.Image pinImage = null;

     

        System.Net.WebRequest req = System.Net.WebRequest.Create( pictureUrl );

       using( System.Net.WebResponse response = req.GetResponse() )

     

       using( System.IO.Stream stream = response.GetResponseStream() )

     

       {

     

       pinImage = System.Drawing.Image.FromStream( stream );

     

       }

        //PictureProperty is the name of the Picture control - your's might be a different name

        Picture PictureProperty = rpt.Sections["Detail1"].Controls["PictureProperty"] as Picture;

     

        PictureProperty.HyperLink = pictureUrl;  

     

        PictureProperty.DataField = pictureUrl;

     

        PictureProperty.Image = pinImage;
    0
  • John Nerge

    My process is quite a bit different. I am using a subreport on the main report. The subreport is just a reference to a data link that's set up on the parcel layer in my site. That data link runs a query to pull the photo with the matching parcel ID from a different SQL Server db (I use a one to one relationship because I only want the most recent photo, but you could also set it up as one to many for multiple photos).

    I would think this could be done with attachments as well.

    0
  • Permanently deleted user

    If anyone can provide a bit more info about how to add attachment images (png/jpg/gif) to reports we would love to hear about it.

    We will need to do this soon.

    0
  • Permanently deleted user

    This is an interesting topic as this applies to documents too.

    We have a lot of photos linkied by the file name and point id.

    All our photos are stored in a file system and we extract the photos using a coldfusion page listing all the associated photos for a point as a hyperlink.

    We've been looking at using attachments and datalinking methods also...

    ken

    0
  • Permanently deleted user

    Has anyone found a solution for showing attachments in a report?

    Thanks, Barbara

    0
  • David Major

    I just struggled with this but think I have it working. It is based on the a combo of the suggestion by John in this thread, and Peter's scripting to add a picture to a report via a link. I made a Data Link to the attachments table in SQL Server. Then made a subreport on that table and added a picture control and text box in the subreport. I constructed the link using the attachment table info. Here's my sloppy version of the script:

    public void Detail1_Format()

     

    {

     

     if ( rpt.Fields["ATTACHMENTID"] != null)

     

     {

      //get params from the attachments table

     

      string doctype = Convert.ToString( rpt.Fields["CONTENT_TYPE"].Value); 

     

      string objID = Convert.ToString( rpt.Fields["REL_OBJECTID"].Value); 

     

      string attachmentID = Convert.ToString( rpt.Fields["ATTACHMENTID"].Value); 

     

      string fileName = Convert.ToString( rpt.Fields["ATT_NAME"].Value);

      //build the link

     

      string attachmentURL = "[link to your mapserver/feature server feature class]" + objID + "/attachments/" + attachmentID;

      //init the picture and textbox

     

      Detail Detail1 = rpt.Sections["Detail1"] as Detail;

     

      Picture Picture1 = rpt.Sections["Detail1"].Controls["Picture1"] as Picture; 

     

      TextBox TextBox1 = rpt.Sections["Detail1"].Controls["TextBox1"] as TextBox;

     

          

     

         if (doctype.Contains("image"))

     

      {

     

      

     

         System.Drawing.Image pinImage = null;

     

         System.Net.WebRequest req = System.Net.WebRequest.Create( attachmentURL );

     

      

     

         using( System.Net.WebResponse response = req.GetResponse() )

     

         using( System.IO.Stream stream = response.GetResponseStream() )

     

         {

     

         pinImage = System.Drawing.Image.FromStream( stream );

     

         }

     

      

     

          //set properties of picture control and text box

     

          Picture1.HyperLink = attachmentURL; 

     

          Picture1.DataField = attachmentURL;

     

          Picture1.Image = pinImage;

     

          TextBox1.Text = fileName;

     

      }

     

      

     

     else

     

      {

     

       Picture1.Image = null;

     

       Detail1.Height = 0; 

     

      }

     

        

     

     }

     

    }

     

    0
  • Permanently deleted user

    Thanks so much for the code.  I am getting an error though:  "There was a workflow error running activity: Error running report 'Timeout exceeded'".  Maybe I have too many attachments?  I am trying to find a solution to extend the time limit of 60 seconds.  Any suggestions?

    Barbara

    0
  • David Major

    No problem, hope it works for you. I think you can set the Timeout time like this: req.Timeout=10000; (milliseconds) though I haven't tried it.

    http://msdn.microsoft.com/en-us/library/system.net.webrequest.getresponse(v=vs.110).aspx

    David

    0
  • Permanently deleted user

    David,

    I found out my timeout issue was because my subreport wasn't set up correctly.  How did you configure your subreport using the datalink table?

    Thanks, Barbara

    0
  • David Major

    Hi Barbara,

    Here is the data link SQL, the link in manager is called InspectionAttachments:

    SELECT ATTACHMENTID, REL_OBJECTID, CONTENT_TYPE, ATT_NAME, DATA_SIZE, DATA FROM Vector.sde.HYDRANTINSPECTIONS__ATTACH WHERE REL_OBJECTID = @ObjIDLink

    The subreport field ReportName is InspectionAttachments, and the tag is the [filename].rpx of the subreport file.

    That what you mean?

    David

    0
  • Permanently deleted user

    David,

    Thank you so much!  I got it to work after I fixed the SQL Statement.

    Barbara

    0
  • Permanently deleted user
    I know this thread is quite old, but I was wondering if anyone had any suggestions of how to resize the photos once they are in the report. We have a site that allows a user to take and submit a photo that is then stored in a SQL database as a varbinary. We then have another site that allows our inspectors to view the photo in a report. However, the photos are so large, only a quarter of the photo shows up on a page...Any ideas?

     

    User-added image
    0
  • Permanently deleted user
    Hi Lisa, 

     

    If you want to resize your photos, all you need to do is go to the Report Designer, click on the photo container, then in the properties on the right hand side, there is a setting called "SizeMode". If you can set it to "Stretch", that should fix your problem. 

     

    I hope that helps.

     

    Carmen
    0
  • John Nerge
    Lisa, a non-technical question: What in heaven's name is that a photo of?
    0
  • Permanently deleted user
    Hi All, 

     

    I am attempting to add attachments to my report following the above instructions, but its not working? I don't get any errors. But I don't get pictures in report either? Any help would be much appreciated. Thanks. 

     

    Nataliya
    0
  • Permanently deleted user
    Hi Nataliya - I am having the same problem as you - the report is running but no pictures. Did you work out what the problem was?

     

    Inga
    0
  • Permanently deleted user
    Inga,

     

    No, I still don't have a solution. How about you? 

     

     
    0
  • Permanently deleted user
    Hi Nataliya, 

     

    I have just received info from support my issue is bug in Essential 4.5.1. It has been fixed on 4.7.1. 

     

    see reference:

     

    GE-6972: Report doesn't include datalink data if the field used as a parameter in the SQL query is of type esriFieldTypeGlobalID

     

    GE-6972: Subreport cannot retrieve data from Data Link if the link field is a Global ID field
    0
  • Permanently deleted user
    Inga, 

     

    I am on Essential 4.7.1.42. So it has to be something that I am doing wrong. Have you updated your Essentials and tried it? Thanks.
    0
  • Permanently deleted user
    It's likely not you, Nataliya. I just took a quick look at the release notes, and GE-6972 was actually resolved in 4.8. I've confirmed this in our issue tracker.

     

    If you're considering upgrading, Essentials 4.8.2 will be generally available on Monday (August 21st).
    0
  • Permanently deleted user

    Jordan,

     

    We upgraded our Essenials to 4.8.2 and I tried my report/subreport, still nothing - blank page. Below I added screenshots from some of my settings, maybe someone can spot something I am doing incorrectly. 

     

    Thank you,

     

    Nataliya

     

    Script:

     

     User-added image

     

    DataLinking:

     

    User-added image

     

    Subreport name:

     

    User-added image
    0
  • Permanently deleted user
    Nataliya,

     

    Are you still having an issue?  I was able to add a picture to the subreport and set the data field to to DATA and the attachments insert themselves without the script.

     

    Hope this helps if you didn't get it working!

     

    Mandy
    0
  • Permanently deleted user
    Mandy,

     

    I haven't figured it out yet. So I will try your suggestion. 

     

    Thanks,

     

    Nataliya
    0
  • Permanently deleted user
    Thank you Amanda and other contributers, I have tried again and finally got the attachments in my report ! A happy day for me.
    0

Please sign in to leave a comment.