Printing Images in Visual FoxPro 9.0
Posted by Rey Dacoco
There are plenty of ways to do this and one of the easiest way by far is by using reports but since I can’t help but be attached to old things, we’ll do it the old way, the FoxPro for DOS way.
1. Design your form as follows:
2. Double-click the control named PrintButton and enter the following:
*Turns on the printer SET PRINTER ON *Prevent the data being printed from appearing on the screen SET CONSOLE OFF *Sends whatever specified in the @SAY command directly to the printer *This is one of the important lines of code, without this, the image * will not be printed at all SET DEVICE TO PRINTER *Displays an explainatory text just to let the user know that the data is being printed WAIT WINDOW 'Printing...' TIMEOUT 3 *Displays our image in a specified row and column coordinate *We use stretch so that the size of the image will adjust to *the size of the image control @ 1,5 SAY Thisform.iconimagecontrol.picture BITMAP SIZE 5,10 STRETCH * Displays our text @ 6,5 SAY 'Application Name:' + thisform.Appnamelabel.Caption *Ejects the paper EJECT *Stops sending data to the printer SET PRINTER OFF3. Here's the code again and this time I’ve omitted the comments coz it's kinda messy or something:
SET PRINTER ON SET CONSOLE OFF SET DEVICE TO PRINTER WAIT WINDOW 'Printing...' TIMEOUT 3 @ 1,5 SAY Thisform.iconimagecontrol.picture BITMAP SIZE 5,10 STRETCH @ 6,5 SAY 'Application Name:' + thisform.Appnamelabel.Caption EJECT SET PRINTER OFF
4. Double-click the ExitButton and enter the following:
*Quits the form RELEASE THISFORM
5. Click the Run icon or press CTRL + E> Click the Print button. Here’s a sample print out of how it should look like. I’ve tried it using EPSON LX 300 printer.

6. So there...