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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Generating PDF Document 1

Status
Not open for further replies.

Steve Meyerson

Programmer
Sep 17, 2020
320
US
I updated my app to include all reports (about 40) and their image files in the project instead of on the user's machine. I create pdf's from them by using Object 10 in Foxypreviewer. Example:

REPORT FORM Step1 OBJECT TYPE 10 NEXT 1 NOCONSOLE TO FILE 'Step1.pdf'

The reports create the pdfs fine when running the exe on my Win10 desktop. But when I run the same exe on my Win10 laptop, I get this error message for the reports having jpg or bmp image files.

Error generating the pdf document
Error code: 4184
Description: Unexpected EOF marker was detected

[URL unfurl="true"]https://res.cloudinary.com/engineering-com/image/upload/v1636214443/tips/ErrMsg_l8rhdn.bmp[/url]

My desktop machine has VFP9 installed. Laptop does NOT (this because I try to emulate my client's laptop without VFP, but includes FoxyPreviewer.app, for final testing of my exe).

I created a simple test project & exe with a report without an image file. It ran fine on my laptop. So I thought it might be an image file path problem.

The path must be specified when creating or editing the report. However, I noticed the path does NOT appear in the frx file - only quotes around the jpg file name in the Picture field of the ObjType=17 record.

Any other ideas? Thanks for any help.

Steve
 
Steve,

I'm not sure about this, but I suspect that the filename you are seeing in the FRX is relative to your default directory, which for some reason is different on your laptop compared to your desktop. If that's right, the solution might be to ensure that the image directory is in your search path (as specified by SET PATH).

Alternatively, ensure that the images get bound into the EXE (by not specifically excluding them within the project). But that second option would only work if the images are static, that is, they are not user-generated in some way.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike.

I'm not sure I understand. The image files are INCLUDED in my project as well as the frx's.
They are physically located on the desktop in .\Reports, right below the exe's folder.

On the laptop I assume they are all "built" into the exe so they don't exist anywhere else on the laptop.

I also assume the default paths lead to the program (exe) folders on each machine. It's on E:\ for the desktop and C:\ drive on the laptop. I might try changing that to make them both C:\ since the client's machine will use C:\.

As another long shot, I'm wondering if I eliminate the quote marks around the file names in the Picture field if that will make a difference. (There are no spaces in the names.) I'll try it when I get the chance.

If that doesn't work, I'll keep trying anything I can think of. [afro2]

Steve
 
Hi Mike,

Just FYI, I removed quotes from an image file name in the Picture field of the frx.

As you can probably guess, it didn't work. Couldn't find the file, asked user to find.

Steve
 
Steve,

Sorry if my earlier post wasn't clear. However, the fact that your image files are bound into the EXE will override what I said about relative paths. If the files are bound into the EXE, I would have thought that VFP would be pretty well guaranteed to find them. I don't know why that is not happening.

Just to pick up your other points. The fact that your image files are in a folder directly under your EXE's folder doesn't mean that they are in the search path. You would have to do [tt]SET PATH TO Reports[/tt] to achieve that. Note that the path to the Reports folder is relative (to your default directory), so you don't need to give it the full path here.

You asked about changing the drive designation from E: to C:. This is not a good approach. In general, you should avoid hard-coding drive letters and directory paths within the application (for the simple reason that they might change, outside your control). A better way of establishing your default drive and directory is like this:

Code:
SET DEFAULT TO JUSTPATH(SYS(16))

This works for both the development environment and when running from an EXE. For the dev env, it sets the default to the directory from which you start the main PRG. For the EXE, it sets it to the folder from which you launch the EXE.

One final point: I try to avoid running an EXE directly from the desktop. This is because any files that the app creates in the default directory (I'm thinking specifically of FOXUSER.*, but there are others) will by default appear on the desktop. This might confuse the user, and might cause problems if the user decides to delete them.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

Thanks for all your pointers. Haven't tried them yet. A couple of points.

I try to avoid running an EXE directly from the desktop.

No I never run an exe from the desktop. By "desktop" I meant the computer on my desk as opposed to my laptop (which is actually on a different desk). Sorry for the confusion.

I wish I( knew which file "Unexpected EOF marker" is referring to. I checked a couple of the report files. My frx's last byte is 1A. Not so with the frt files. That might be normal. I don't know. BTW, jpg's end with D9, bmp's with 00 00.

Mike said:
The fact that your image files are in a folder directly under your EXE's folder doesn't mean that they are in the search path. You would have to do SET PATH TO Report

I will do that. But I would think so long as they are found in the project (which they apparently are - the image files are in the same folder as the frx's), then the default path shouldn't matter because isn't the first place VFP looks for a file always is the folder where the exe starts (and contains all the dll's, FoxyPreviewer.app, etc? Am I wrong here?

I agree changing E:\ to C:\ should make no difference. Who knows, weird things happen I can't explain. [sadeyes]

Steve

 
By "desktop" I meant the computer on my desk as opposed to my laptop

Oh, yes. Of course. I should have realised that was what you meant. Silly me.

My frx's last byte is 1A. Not so with the frt files. That might be normal. I don't know. BTW, jpg's end with D9, bmp's with 00 00.

Yes, 1A at the end of your FRX is completely normally. It equates to CHR(26), which is the standard ASCII code for end of file. I don't know if the D9 or OO for the JPEGs and BMPs is normal, but I doubt if it would generate an error within VFP if it wasn't.

I would think so long as they are found in the project (which they apparently are - the image files are in the same folder as the frx's), then the default path shouldn't matter because isn't the first place VFP looks for a file always is the folder where the exe starts (and contains all the dll's, FoxyPreviewer.app, etc? Am I wrong here?

It is not quite true that the first place that VFP looks is in the folder from which the EXE starts. That's true only if you don't explicitly change VFP's default directory (with SET DEFAULT or CD). But, in any case, that won't be relevant if the files are bound into the EXE. In that case, VFP will always find them, regardless of where the actual files reside on your hard drive (or even if they are not present on the hard drive).

Note that being "found in the project" isn't the same as being bound into the EXE. For a file to be bound into the EXE, it must be in the project AND not explicitly excluded from the build. A file will be excluded if there is a little circle containing a diagonal line next to the filename. You toggle the included / excluded state by right-clicking on the filename and choosing the appropriate option.

I hope this all makes sense.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I hope this all makes sense.

Yes it does. Your explanations are always clear (to me, anyway).

I'm aware of the exclude/include toggling, so I don't think that's a problem here. All my reports are "Included" in the "Reports" section of the project. All the jpgs & bmps are "Included" in the "Other Files" section.

I think I've narrowed it down to the images. Although the error msg on the laptop prevents me from going further, the pdfs are actually created anyway, in the appropriate folder. I can even open them in the Adobe pdf reader. They appear normal except NONE of the images appear in any of the pdfs.

I have a feeling it's something very simple. I just need to find it. [As is true in many aspects of life] [sunshine]

Steve
 
Hi Tom,

The image file does NOT exist on the machine running the exe. Reason is I'm trying to avoid that. There are over 20 of these files I would have to install on each client machine (which I could but would rather not). At this point I don't even know if that would solve the problem anyway. I'll try it first on my own laptop.

Your link describes my problem exactly (2013). Thanks for that. No solution however, but a few suggestions in the responses which I will try, e.g. versions of FoxyPreviewer.app and the dll's. Also "clip"/"stretch" choice in the report creator.

Thanks again for your help.

Steve
 
Steve,

As far as I can see, the link that Tom posted could indeed provide the solution. Have you checked that you have FOXYGETIMAGE.PRG in your project (and included in the EXE)? (As per page 55 of the documentation.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
BINGO!!![highlight #204A87][/highlight]

Magic Mike said:
Have you checked that you have FOXYGETIMAGE.PRG

That did it!

This is the last paragraph in FoxyPreviewer documentation.pdf
Code:
[b]Images embedded in my EXE aren’t printed[/b]
In the sources folder you can find the file "FOXYGETIMAGE.PRG". Include this file in your EXE 
project if you have images embedded in your EXE that you want to appear in your report. This may 
bring some security issues to your EXE, because this program will allow FoxyPreviewer to access the 
embedded images of your EXE.

Guilty... I didnt RTFM.

I included it in project, built the exe, copied the exe to laptop, and Voila!.

Thank you, thank you, thank you!

Steve
Grateful Forum Guy
 
Tom & Mike (Team effort),

I had searched some but I missed Tom's link, so I'm thankful for that.

I thought I searched through all 8-10 responses to that item, but to be honest, I don't remember coming across the FOXYGETIMAGE.prg post, but obviously I missed it.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top