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

how do i customize the paper size in reports? 1

Status
Not open for further replies.

myzani

Programmer
Jan 20, 2010
10
PH
hello guys,

The report prints to letter size 8.5 x 11 perforated sheets of paper. The actual page size is 8.5 x 6, I am having difficulty controlling the page advances the printer. The report is treating it as a true 8.5 x 11 sheet of paper, whenever the report overflows a page full page advance occurs.
By the way, I manage to half the size of the paper in preview.

Thanks...
 
Myzani,

If your printer supports custom paper sizes, define your custom size in the printer properties. Then, in the report designer, use the Page Setup dialogue to select that size.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
I was going to suggest something similar to what Mike suggests above, but with a slight variation.

"If your printer supports custom paper sizes, define your custom size in the printer properties."

Instead of storing the unique printer properties within the VFP Report Form where it could unintentionally be deleted with a Report Form Hack, define a unique Windows Print Driver for your printer with the paper size specified and have it saved within your Workstation Printers separate from any 'standard' Print Driver for the same printer. Make certain that it is named distinctly.

Then when your VFP Report needs to be printed, merely utilize that Windows Print Driver instead of the other one.

Good Luck,
JRB-Bldr
 
hello MikeLewis and Jrbbldr thanks for the suggestion.

I would like to follow-up some question regarding on this. Let's say that I'm getting the exact results but what if the another user or client would use this and this user/client don't know about setting up printer page set-up? For this reason he's getting the default set-up which is Letter.

 
If you use Mike's suggestion the printer setup is in your VFP Report Form and will be available to any user who uses it without their even having to know about it. That will work just fine.

But if you should inadvertently 'hack' your VFP Report Form at some future time you could very likely lose the settings.

If you use the unique Windows Print Driver for the printer specifying the use of paper that size, then the Application code will be responsible for changing the Windows Print Driver utilized and not the user.

Therefore as long as the other users also have that unique Windows Print Driver installed and configured in their workstations, then all will be fine.

Good Luck,
JRB-Bldr
 
Hi Jrbbldr,

Can you please provide me some links for this unique windows print drive...


thanks...
 
Myzani,

I agree with JRB-Bldr.

Basically, what we're suggesting is that you go through the steps of re-installing the printer (that is, the printer that supports the custom paper size), even though the printer was already installed. In Control Panel, it will appear as two separate printers.

Now, go to the property sheet of the printer you have just installed. In the appropriate box, enter a new name for the printer. Call it, say, "VFP printer" (that's just an example). The box where you enter the name will vary with the make and model of printer, but it's usually the first box on the General page.

Next, use the properties sheet to specify the custom page size. How you do that will again depend on the make and model. In my HP Laserjet P2105, for example, I go to General / Printing Preferences / Paper/Quality / Custom. I the enter the measurements, and give the custom paper size a name.

Finally, OK out of the dialogues to save your settings.

In the report designer, specify the custom paper size name in the Page Setup dialogue.

To print the report, either programmatically set the printer to the name you gave the new printer ("VFP printer" in this example), or use the PROMPT clause so that the user can select the printer.

Obviously, this relies on the user also following the above steps to set up the printer driver. You might be able to partly automate those steps by using the PrintUI.DLL, but you would still need some way of specifying the custom paper size. If you want to follow that up, see
Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
"Can you please provide me some links for this unique windows print drive..."

As Mike has indicated above, you don't just download a UNIQUE print driver - you create it yourself (or your users do it) by installing a 2nd copy of the STANDARD print driver and configuring it as needed - naming it in a unique manner. Also, make certain that it is named EXACTLY the same on EVERY workstation so that it can be utilized by your code.

Then in your VFP code, when you want to use this unique print driver, you will need to have your code utilize it so that the user need not be involved at all.

One way that I do that is as follows:
Code:
* --- Determine Existing Default Windows Printer ---
lcDefaultPrinter =  SET("PRINTER",2)

* --- Use APRINTERS() To Determine What Print Drivers Are Installed ---
=APRINTERS(gaPrinters)

lcNewPrinter = "VFP Printer"  && Example Print Driver Name
IF ASCAN(gaPrinters,lcNewPrinter) > 0
  * --- Yes, The VFP Print Driver Is Installed ---

  * --- Use Windows Scripting To Set Default Printer To New 'VFP Printer' ---
  ONET = CREATEOBJECT("WScript.Network")
  ONET.SetDefaultPrinter(lcNewPrinter)

  SET PRINTER TO NAME (lcNewPrinter)

  * --- Print Report Form Using VFP Printer ---
  REPORT FORM MyReport TO PRINTER NOCONSOLE

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

  SET PRINTER TO NAME (lcDefaultPrinter)
ENDIF  && IF ASCAN(gaPrinters,lcNewPrinter) > 0

Good Luck,
JRB-Bldr
 
hello jrb-bldr

Correct me if I'm wrong but as I understood to your code this is to be assumed that only one printer and printer driver is installed but what if every individual user has it's own printer with different products?

 
"what if every individual user has it's own printer with different products"

You have not mentioned that before, we have been advising you under the assumption that you had one set of users ALL using the same type of printer for which you would create a specialized Print Driver.

If you are intending this to become a generalized application to be used by a wide audience of users each with possibly a different printer requiring its own unique printer configuration, you have opened a whole new "Can of Worms" which neither Mike's suggestion nor my own was intended to address.

You might want to look at a couple of Microsoft articles:
How to control printer attributes for a report at run time

How to find PaperSize for custom print sizes under Windows NT and later versions by using Windows API functions

Good Luck,
JRB-Bldr
 
It funny what you can find if you just get "creative" with a Google search.

I did a Google Search for: Papersize VFP and found a number of 'finds'. Two of which I listed above.

I did find another one that could possibly be of use:
custom paper in vfp report

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top