Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Bmp in frx/pdf and Image Field

Status
Not open for further replies.

teoparra

Programmer
Sep 27, 2011
7
IT
Situation:
I store in a Image field an image (.BMP) in binary format from a 9.0 Visual Fox Pro application with his own database.
Then, the application writes the content of this field in an Image Field of an external database, managed by an 8.0 Visual Fox Pro application.
I have to read this field, display it in a form and then print it in a report. (it must be also possible to display it in a pdf file produced by the report).
The commands I use in order to manage the image field are STRTOFILE e FILETOSTR

Problem:
The 8.0 Vfp application creates the .BMP file on disk, displays correctly the image in the relative form as well as in the report preview.
It doesn't show the image when the report is exported as pdf (.frx) and when the .frx is printed (on paper).
 
It's hardly a fopro issue, if you see the image in the report preview but not on paper or in pdf.

What's SET("REPORTBEHAVIOR"), are you using a reportlistener making a difference in preview and final result? That's possible and the only thing coming to my mind that would make such a difference of preview vs final output.

A second isse, maybe: What printer is set? Generic Text? Any printer driver not including images? What do you use to create a pdf? A PDF printer driver? Which?

Bye, Olaf.
 
Hi Olaf, first of all thank you for your reply!!

REPORTBEHAVIOR and reportlistener are not features available in Vfp8, so, i don't think this could be the reason.
it could be the way i use to store the file in the Image field ?

I write from the Vfp9 based application with the following code:

cImage = GETENV("temp")
cImage = Addbs(cImage) + '\Tmp_INK.BMP'
xIMGFRM = Createbinary(Filetostr(cImage))
[...]
appostr= "update "+TableName+" set INIMGFRM=?m.xIMGFRM where Condition"
=SQLExec(handle,appostr)
 
Hi Teoparra,

You say the image shows up in your form, and in a report preview, but not when you print the report to paper or to a PDF.

If that's right, then the issue has got nothing to do with how you extract the image from the FoxPro table or store it in the external database. It's more likely to be a printing or PDF issue.

Just to be clear: When you include the image in the report, are you referencing the actual BMP file on disk, or a General field in a table or cursor?

If it's the physical BMP file, then the problem is probably to do with paths. Make sure that the BMP is in the default directory or the search path at the time the report is printed. Alternatively, include the path with the filename when you reference it in the report.

This is especially important when you output to a PDF. The reason is that the PDF driver will often change the Visual FoxPro default directory to point to the directory to which it is writing the PDF. For that reason, it's a good idea always to save the default directory to a variable before printing, and to restore it afterwards.

In fact, I would suggest you do just that before you do anything else.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
You're setting the INIMGFRM field to the image retrieved from disc. You should rather reference the image file in your report´, works much better.

Bye, Olaf.
 
I can't test your solution, Mike, before tomorrow, then I'll certainly reply to you.

Meanwhile I can explain my situation with an example of the report.
I don't include a file in the OleObject in which I show it (by choosing it from disk) but I put a variable in which I write the full path of my BMP.
In the attached file you can see how the image is included in the report.
L_FileName is assigned by the .prg who execute the report with the following code:

L_FileName = GETENV("temp") + '\Tmp_INK.BMP'
(Assuming the file really exists in the folder)
 
 http://www.mediafire.com/?d6b7pa13ud3jf5r
I see, the report uses an image file already.

but then I don't see why you do
Code:
UPDATE ... set INIMGFRM=?m.xIMGFRM
which sets a field in a table.

It doesn't matter much, if that is not the source of the report. But that would explain, if the problem was not between preview and print, but between form and report.

If the form does display the image via that field and the report does print via the file, the problem may simply be a wrong path.

Your upload to mediafire doesn't help me, RAR is not a format I can open here, I'm at a customer, not able to install something capable to open RAR archives, so I need to guess about the report itself.

Perhaps check what GetEnv("temp") gives you in VFP9 vs VFP8. You can double check if the file is in L_Filename via FILE(L_FileName), of course. Assuming isn't knowing.

Bye, Olaf.

 
The error may simply be a backslash too much here:

Code:
cImage = GETENV("temp")
cImage = Addbs(cImage) + '\Tmp_INK.BMP'
Addbs() is good, it adds a backslash to the temp directory, if there is one missing, but you add another one via '\Tmp_INK.BMP'.

On the other side you do:
Code:
L_FileName = GETENV("temp") + '\Tmp_INK.BMP'

In fact both may end up with a wrong filename.

You should do the same on both sides, preferably...
Code:
cImage = Addbs(GETENV("temp")) + 'Tmp_INK.BMP'
...on the one side and...
Code:
L_FileName = Addbs(GETENV("temp")) + 'Tmp_INK.BMP'
...on the other side.

Or you simnply pass the filename, eg via a table.

Also (just to state the obvious) GetEnv("temp") is by default a local folder, so you can't exchange files via a temp dir, if the applications are not running on the same computer, then you'd rather need to store the files in a central folder accessible by bothe applications, eg side by side to a DBF file both apps access.

Bye, Olaf.
 
No no no... Olaf... there's a misunderstanding!

1-Rar is a compressed file, you can open it with WinRar
2-look at my report, now you can find it in .frx format following the link below:
ASTE_QIN.FRX: ASTE_QIN.FRT:
I don't display the Image field, but a variable in which I put the path of my BMP.
Don't consider the construction of my path, look simply at this assignement:
L_FileName = GETENV("temp") + '\Tmp_INK.BMP'
(Assuming the file really exists in the folder)

Then, I put L_FileName in the Ole Object.
 
Teoparra,

don't you want to understand?

I said I can't install a software capable to extract a RAR archive. I know the format and could work with it from my office or at home.

It would help, if you upload a ZIP, as that is what plain Vista can extract, but not RAR. WinRar is not part of windows. Like WinZip (which by the way could also extract RAR, The Win is just in the name, but it's not part of windows).

I'm a guest here at our customer, I can't install anything, I don't have administrative rights!

In regard of the file name, you were showing two different code section of your two apps, and they don't match, on the one side you're putting one more backslahs on your filename then on the other side. It may not make a difference, as Windows is forgiving about double backslashes and simply would ignore them, but still you better use the same approach on both sides to create the file name.

Bye, Olaf.
 
Anyway, your issue is likely nothing inside your application or the report, but has to do with printer driver features or settings, especially since the previews shows the image OK.

Besides that I only can ammend what I see and I did so. Besides that, I made the assumption you may be reporting a wrong issue, as it doesn't sound quite real to have a difference in preview vs. print, but you could very easily have a difference of form vs report. And maybe you got a wrong error reported by users. I don't know if you sit there and test yourself or only describe what's been told to you.

Bye, Olaf.
 
Teoparra,

It might also help to know what method you are using to generate the PDFs.

If the problem only occurs either when ouputting to PDF, or when printing after outputting to PDF, then it's likely that my point about the PDF driver changing the default directory was correct.

To check that, just trying issuing SYS(2003) the next the problem arises.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
look at my report at this url:
(.FRT) - (.FRX) -
in this report i have 2 images, the first doesn't works as I want, the second is correctly working.

the first image refers to a variable calculated in this way in the .prg with which i execute the report: L_FileName = GETENV("temp") + '\Tmp_INK.BMP'

the second image refers to a file with full path wrote by hand
 
In your report both pictures are setup wrong.
In the properties tab the one is set as:

Controlsource Type: Expression or variable name
Controlsource: L_FileNamL_FileName

This means wrong variable name.

The other control is set as:

Controlsource Type: Expression or variable name
Controlsource: c:\mybmp.bmp

I wonder how you see anything, both report controls shouldn't show anything.

In the first example the controlsource is a wrong variable name, in the second case you sepcify a valid file name (I assume, but don't set the controlsource type to file name.

When using a variable, the REPORT FORM command must be in the same method defining the variable, unless the variable is private or public. The variable has to be in current scope.

Both ways would work, if set up correctly and print both in preview and output, using the Bullzip pdf printer driver I get a picture in the PDF both ways, too. And other PDF printer drivers should also work.

When I setup the report as wrong as you did I get a syntax error, when executing it via REPORT FORM from the control havin set the filename but type expression and if I remove or fix that I get a variable not found error.

Do you do any error handling?

Bye, Olaf.


 
Solved
The image I display in the form from which I launch the report is the same I print on it.
Until the image is associated to a Image object, my vfp8 application put on it a lock (in fact you can not eliminate it from the disk until the application don't release it).
In this situation, the image is displayed in the report preview but then (and I have yet to understand why) the image file is still locked and cannot be used when printing or exporting to PDF.
Unfortunately, the report does not warn with an error message, just not the image is reproduced.

It would seem to be a problem with the release of Visual FoxPro 8.0, with Release 9.0 I have not found the fault.

To solve the problem I simply duplicate the image with a new name before the launch of the report, then I include thi new file in the report and as final step, I delete the new image from disk.
In my form I always refer to the original image.
 
A file being locked in one process would explain, why it's not available to the pdf driver as a seperate process, but as you have a vfp8, a vfp9 and a pdf process in the play I don't see how the sharing of the same file would work between the two foxpro processes alone, unless I still have a wrong idea of what you really do in what application.

I also had the understanding you copy the image out of a blob or memo field anyway, so the file is seperate anyway.

We may have been of more help with a better description of the things involved. Well, problem solved anyway.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top