Images In Functions

Images In Functions

Forum member · Sep 7, 2006
Hi, is it possible to add an image to the body of a page using a function? If possible, I would like to add an image based on the value of a Field (i.e. a tick for yes and a cross for no). Thanks.

Re: Images In Functions

Support · Sep 7, 2006
Hello, Yes, it is possible to add the image using the fucntion without any problem. Following is the sample code snippet: ' Put this code in body element of your code and it calls the SetImagePath function to decide which image to use based on the value of the field Set image = .AddImage("",0,0,16) Set image.OnPreDraw = GetRef("SetImagePath") ' Function to selct which image to use Function SetImagePath(objImage) if m_objReport.RecordSet("Field") > 30 Then objImage.FileName = "C:\Temp\tick.jpg" else objImage.FileName = "C:\Temp\cross.jpg" End If End Function Thanks, ceTe Software Support Team

Re: Images In Functions

Forum member · Sep 8, 2006
Hi again, I have tried what you suggested as you can see below: 'In the body Set image = .AddImage("", 425, 0, 14) Set image.OnPreDraw = GetRef("SetImagePath") 'Function Function SetImagePath(objImage) if objReport.RecordSet("DaysOD") = 0 Then objImage.FileName = Server.MapPath("icon_Yes.png") else if objReport.RecordSet("DaysOD") > 0 Then objImage.FileName = Server.MapPath("icon_No.png") End If End If End Function However, I receive the error "Image file not found." Placing the following in the body works fine, so i know the image path is correct and working: 'Body .AddImage Server.MapPath("icon_No.png"), 425, 0, 21 Have you any idea why this is happening? Thank you.

Re: Images In Functions

Support · Sep 8, 2006
Hello, Can you try to print the path of the image before it tries adding the image, to make sure that it is resolving the path to the image correctly? Also can you please try entering the full path to the image in the function and see if that solves the problem or not? Thanks, ceTe Software Support Team

Re: Images In Functions

Forum member · Sep 12, 2006
Hi, I have this wotrking now, thank you for all the help. However, i receive the error 'image has an alpha channel' when i attempt to use an image with a transparent background. Am I right in thinking that they are not supported, or is there a way around this? I am using an interlaced png image produced in photoshop. Thanks again.

Re: Images In Functions

Support · Sep 12, 2006
Hello, The likely reason you are getting the error is because the image file you are using has an alpha channel. Our DynamicPDF™ Generator and ReportWriter products only support JPEG and PNG images (PNG images with an alpha channel are not supported). In v3.0 of our COM/ActiveX product we have added support for several image formats like Jpeg, Jpeg 2000, Png, Bmp, Emf, Exif, Gif, Tiff, and Wmf. Thanks, ceTe Software Support Team

Re: Images In Functions

Forum member · Jul 28, 2017
Potentially a stupid question, but is there a way to determine if a PNG is inter-laced? If possible, I would like to allow PNG images to be used by my application, but if I need to disallow PNG as part of my applicatin/upload process, then so be it. Thanks. David

Re: Images In Functions

Support · Jul 28, 2017
Hello David, It is not possible to verify or determine whether the PNG image is inter-laced or not using DynamicPDF for COM/ActiveX products. Thanks, ceTe Software Support Team.