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

Programmatically selecting user-defined paper size

Status
Not open for further replies.

rianeiromiron

Programmer
Jul 1, 2001
151
GT
Hello all!

Is there a way to programmatically select a user-defined paper size?

The case is this

I have several applications, all of them are in fact VFP6 .EXEs files. I use a printer, for example a Epson LX-300+ and a user-defined paper size, for example INVOICES (I'm using W2000 and the paper size is defined in the Print Server as INVOICES). The problem is that the printer is used to print letters, sheets (Word, Excell, etc.) and I don't want the users to select manually the INVOICES paper definition.

As far as I know, since I'm using .EXEs I won't be able to hack the definition for the printer in the INVOICE.FRX (remember the old trick?) dbf.

Does anyone have any idea on how to solve this?

If there is a solution, would also work in WinMe?

Thank you all.

Rianeiro
 
Let's say you have the report invoice.
You can modify page layout, even the printer if you do this:

use invoice.frx

The first record and field expr have something like this:

DRIVER=winspool
DEVICE=HP DeskJet 600 (Color)
OUTPUT=LPT1:
ORIENTATION=1
PAPERSIZE=9
DEFAULTSOURCE=7
PRINTQUALITY=300
COLOR=2
YRESOLUTION=300
TTOPTION=1

This is a memo field and you can modify this.
 
As far as I know, since I'm using .EXEs I won't be able to hack the definition for the printer in the INVOICE.FRX (remember the old trick?) dbf.

Can you modify the original report and recompile the application? Or remove the report from the EXE, and distribute the report seperately, and that way you can hack it on-the-fly.
 
Even when the report is in the EXE you can copy it through code in your exe to say C:\TEMP\REP.FRX and C:\TEMP\REP.FRT.

Than you can programmatically change the content (especially the defaultsource) and print that report with the command

REPORT FORM C:\TEMP\REP TO PRINTER NOCONSOLE
 
To mgagnon:

Thanks for your response. I haven't tried that. I'll soon will and tell you the results. Please read the next response:

To JackTheC:

Thanks for your response. I tried your suggestions, however, some things arised:

1) Apparently, in Win9X you can only define one user-defined paper size, and inside VFPs reports, these reports are refered as PAPERSIZE=256, meaning it is a user-defined paper size. But, in Win2000/XP each user-defined paper size has a number, and included in the report's definitions are the fields: WIDTH=XXXX and HEIGHT=YYYY (or something like that). Even if you modify these values just before printing with the report, the report prints with the default paper size.

2) Question: Is it posible to add a user-defined paper size on the fly? (these question comes because maybe modifying the report doesn't work if the paper size is not defined in that computer)

3) Question: How do I know the paper size number asigned to that specific paper size in that computer (so that I can hack)


Thanks all for your responses
 
My answer to my own question:

Doing some research I found a guy somewhere in the internet who came with an application that was able to select printers and paper types. After some translation (most variables were in Italian) I found one can get the printers and paper sizes using DeviceCapabilities in WINSPOOL.DRV (usually in \windows\system folder). He used the "hack the .frx file" aproach and also the "copy to a c:\temp directory a copy of your report" aproach. I made an .EXE file with the application and it worked just fine... in Win98SE (that's what I have at home). I haven't tried in Win2000 (that's what I have at work). We are on a holiday in my country and I'll try in a couple of days. (Am I the only taking office work to my home?)

This story will continue...

[thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top