Images In Functions

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF ReportWriter for COM/ActiveX (v1)  /  Images In Functions

DynamicPDF ReportWriter for COM/ActiveX (v1) Forum

 Sep 07 2006 10:41 AM
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.
 Sep 07 2006 11:20 AM
Posted by a ceTe Software moderator
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
 Sep 08 2006 4:50 AM
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.
 Sep 08 2006 8:26 AM
Posted by a ceTe Software moderator
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
 Sep 12 2006 4:21 AM
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.
 Sep 12 2006 8:49 AM
Posted by a ceTe Software moderator
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
 Jul 28 2017 7:32 AM
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
 Jul 28 2017 10:20 AM
Posted by a ceTe Software moderator
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.

All times are US Eastern Standard time. The time now is 12:05 PM.