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

Create a jpg img from text

Status
Not open for further replies.

spectrumdata

IS-IT--Management
Dec 5, 2003
13
0
0
US
OK, here's what I'm doing. I have some programs that create stock charts using monospaced text:

x
xo
xox
xox
o

Works fine on the website where I can specify the font. We have to have it like this because of all the add-ins and overlays we use.

Now, I'm trying to use this on a palm/cell phone. The chart looks like hell because I can't specify the font.

What I need is to make a jpg or some other file from the text chart. It will have to be updated every time the users asks for it.

Oddly enough, I've never done this and a day of searching has pointed me exactly nowhere. I'd like to take this text, which is in a memo file, and produce a jpg for the user. Actually any image file would do.

It has to run without user interaction.

Thanks,
John
 

What I need is to make a jpg or some other file from the text chart.

As for some other file, did you think of printing it into PDF?

As for JPG, not probably what you need, but you can look into thread184-769626 for ideas.



 
There are a number of printer drivers out on the web which will "print" reports to an image file (TIF,JPG, etc.).

Here is the one that I have used successfully
But there are MANY more out there.

They can generate image files of varying formats.

To use it:
1. Prepare your report data
2. Set the VFP default printer to the Graphic Printer
3. Issue the Report Form MyReport NOCONSOLE TO PRINTER command
4. Set the VFP default printer back to its original setting.

Good Luck,
JRB-Bldr
 
Thanks folks. Both good ideas. However, we're talking 12 servers here, running Foxweb with 10 channels each. I really don't want to get into changing printer drivers or having another step. Every second is a potential backup.

I've been messing with ffc/_gdiplus.vcx. It looks like it might work but I'm getting all kinds of errors.

Calvin Hsia's page has an example but I can't seem to get it to work.

Thanks folks.
 
" I really don't want to get into changing printer drivers or having another step."

Just so that you are clear, we are not talking about any extensive code addition.

The Image Print Driver (whichever brand used) is installed onto the Windows workstation just like any other printer. It then is available for use by ANY Windows application including your VFP application.

If it is not the Windows Default Printer, then a few extra lines of VFP code to tell Windows to use another printer. And another few lines of code to set the printer back when done.

Other than that, your REPORT FORM command works as before.

Example:
Code:
* --- Determine Workstation's Existing Default Windows Printer ---
lcDefaultPrinter =  SET("PRINTER",2)

* --- Use Windows Scripting To Set Default Printer To New Image Printer ---
lcNewPrinter = "Image Printer"  && Image Printer 'Name' Defined and Configured In Windows Printers
ONET = CREATEOBJECT("WScript.Network")
ONET.SetDefaultPrinter(lcNewPrinter)

* --- Set VFP Printer To New Image Printer Also ---
SET PRINTER TO NAME (lcNewPrinter)

* --- "Print" Report Form To Image File ---
SELECT RptFile
REPORT FORM (mcFRXFile) TO PRINTER NOCONSOLE

* --- When Done Printing - Use Windows Scripting To Restore Original Default Printer ---
ONET.SetDefaultPrinter(lcDefaultPrinter)
RELEASE ONET

* --- Set VFP Printer Back as Well ---
SET PRINTER TO NAME (lcDefaultPrinter)

Good Luck,
JRB-Bldr
 
Mike -- At the time (and I haven't thought about it since then) I wasn't 100% sure which printer was the one which would REALLY made things work the way I needed, and the client's rush-factor prevented me from pre-testing it to find the answer. So by doing both I guaranteed that it would work as needed - and it does. I merely copied the code above from the working code.

I am sure that you are correct in that only doing the VFP printer would suffice. One of these days when I next modify the client's code, I will go back and eliminate the not-necessary code.

So John (spectrumdata) if you chose this approach, you could get it working with even less additional code.

Thanks,
JRB-Bldr
 

JRB-Bldr,

Thanks for the clarification.

I am sure that you are correct in that only doing the VFP printer would suffice.

I'm not 100 percent certain of that. It just seemed likely.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks JBR. That worked pretty well. However I'm faced with another problem now.

The print driver I found (Zan) produced fine bmp and jpg files. However, my Palm only got a red X when viewing them although Firefox worked fine.. I communicated with the author and he didn't have a clue what could be a problem. I haven't noticed this behavior with the Palm on any other site.

Can you suggest a print driver that might work? I searched and the most promising ones cost $2000!

John
 
My guess is that your problem is not the Print Driver. Its job is to create an image file for you - that's it.

If your Palm is having problems displaying the image file, then it is likely that the problem is related to the specifics of the resultant image itself.

Within the Zan Image Print Driver under the Advanced settings there are a wide variety of options on how the image file can be created (i.e. file format, bit density, separate pages, contiguous page, color/gray scale, etc.)

I would recommend that you first review the "printed" image on your desktop to see how it looks and to verify it has worked OK.

Then you can either examine some of the image files that DO work on your Palm to see what are their parameters - use something like Paint Shop Pro or other image application.

Then go back into Zan and configure it to match. Then try again.

Good Luck,
JRB-Bldr
 
You're right. I've tried every possible format. They're all the same. Opens fine with Firefox but not the Palm. Interestingly, I can open the file with Lview, save it and it shows up great on the Palm.

At any rate, I'm getting it with GDI+. When I get that working, I'll post it. Really pretty simple stuff. I wish I'd started with that.

Thanks
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top