DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Image wont display when added programatically

Solved!
Go to solution

Hello:

 

I am having an issue inserting an image in my Report programatically.  We use GhostScript to convert PDFs to PNGs.  The PNGs are then programatically inserted into the report file.  There are multiple instances of these images being inserted into the report.  Sometimes when I do this, there is no issue with any of the images.  Other times, some images load while it gives me an outline of other images with the address of the image listed at the very top.

 

I'm not sure what is causing this.  Sometimes it loads the all of the images correctly when DIAdem is first started.  Sometimes it works properly if operating out of a different loading folder.  Sometimes smaller image files work, while larger image files don't work (this seems to be the most prevalent factor; files around 200kb work well while 1.5mb files don't load at all).

 

When having an issue with inserting an image, if I bypass programatically adding the image and open the report in DIAdem in order to manually add the image, there are no problems.

 

Any suggestions or help would be greatly appreciated!!

 

 

Thanks,

 

    Set oCtrl = Report.Sheets.Add("TEST")
    oCtrl.Dimensions.Orientation = ePageOrientationPortrait
    oCtrl.Dimensions.UseLocalSettings = True
    If Report.Sheets.Exists ("Sheet 1") Then Report.Sheets.Remove("Sheet 1")
    Dim oImage
    Set oImage = oCtrl.Objects.Add(eReportObjectImage,  "PNG")
    oImage.FileName= "C:\My Documents\image.png"
    oImage.UseOriginalRatio = False
    oImage.Position.ByBorder.Top=11
    oImage.Position.ByBorder.Bottom=5
    oImage.Position.ByBorder.Left=10
    oImage.Position.ByBorder.Width=80
    oImage.Embedded = True

 

0 Kudos
Message 1 of 5
(2,836 Views)

Hi AlexVander,

 

That seems like really strange behavior indeed. I'm not aware of anything in particular that would be causing that, specifically because the behavior is so intermittent. I think there are two main things to go off here, the more frequent occurrences with large files, and the difference between manually and programatically adding the images. 

 

On the first point, does this happen on any other machines? Do you see any other performance issues with your PC or does it seem like your PC is maxing out (or coming close) available memory when DIAdem is running?

 

On the second point, I'm not very well versed in the different implications when adding programatically vs manually and how that might effect the images loading, I'll look into this. Are the images stored locally? And are they all being stored in the same folder?

 

Best,

Selene

Selene
0 Kudos
Message 2 of 5
(2,756 Views)

Selene:

 

Thanks for the reply.

 

I'm currently troubleshooting the script on my laptop and I'm experiencing the same behavior as the machine that normally runs the script so yes, it seems to apply to multiple machines.  As for performance, there shouldn't be an issue: the machine that normally runs the script is only running DIAdem, an Excel sheet, and maybe a few web browsers and Windows Explorer windows.  

 

There is part of our script, however, that seems to bog down the machine:  we pull data into DIAdem from a temperature/humidity logger's stored Excel file.  This Excel file is currently 120mB with a lot of data points for DIAdem to load/process.  This seems to slow down the machine for about 20 seconds during loading and 70 seconds during processing.  I believe all of this happens after the PNG images are added to the report, though.  Other than this, the script operates quickly.

 

The images are stored locally; the script uses GhostScript to pull a PDF off of a network location and convert to a PNG, which gets stored in a local temp folder while the final report is being built.  There are multiple temp folders, based on the type of information stored in the PNG image.  The GhostScript conversion seems to work properly; all of the PNG's are created and stored where they should be.

 

I have noticed, through troubleshooting, that the issue with adding PNGs happens if the name of the file that is in the temp folder doesn't match the name of the file that the script expects to see.  So if the filename is "image1" and the script expects to see "image," then the script won't add the image, in the same manner as noted in the original post.  There shouldn't be an issue with naming; the GhostScript names the PNG images properly and this has been verified by looking in the temp folders after running the report.

 

I'm wondering if, maybe, adding the images to the report overruns the GhostScript.  By this I mean, I wonder if the script is trying to add the images to the report before the GhostScript has finished converting?

 

Please let me know if there is any other information that may be helpful in figuring this issue out.

 

 

Thanks again for the help, 

Alex

0 Kudos
Message 3 of 5
(2,747 Views)
Solution
Accepted by topic author AlexVander

I believe that I have found the issue:

 

The GhostScript conversion was not taking place fast enough to where the DIAdem script ran past it.  DIAdem was trying to pull in images that hadn't been created yet because the conversion was not complete.

 

There had been a pre-programmed Pause in the script (I am troubleshooting someone else's code) but it did not wait long enough for the file conversion to be complete.  I extended the Pause time and it seems to have corrected the issue.

 

I will update if I find any additional problems.

 

Thanks for the help!

0 Kudos
Message 4 of 5
(2,740 Views)

Hi,

 

Excellent, I'm so glad to hear it seems to be resolved! I didn't realize the script was happening 'live', for some reason I though this happened well ahead of time, my apologies for this misunderstanding. However, now, knowing this your explanation makes perfect sense. Hopefully everything continues to work as expected from now on but if you have any questions please don't hesitate to reach out!

 

Best,

Selene

Selene
0 Kudos
Message 5 of 5
(2,731 Views)