Monday, January 6, 2014

Printer Environment on Report, when to save and when not to!

In earlier versions of VFP (before 9), Printer Environment is by default saved onto the report itself.  But then there are cases where because of that, when our app is installed on a client's machine and that machine has a different printer than what we have when we design the report and compiled the app into exe, the report output on the client machine may generate a much different output than what we are expecting like difference on dimensions, margins, font sizes, spaces, some portion cut-off, etc.  And the solution to those problems is to hack into the FRX and clear out these printer environment from within so it will be free of the settings of a "specific" printer.

For these reasons, in VFP9, VFP team saw the need to reverse the process by not saving printer environment anymore within the report.  They made it optional by adding a checkbox in Page Setup of a report that allows us to save or not printer environment.  And by reverse, I mean the default now is it is no longer saved.

Question is, if saving printer environment results to unwanted outputs that has often led developers in lower versions of VFP to always hack the frx files, why should we tick it then?  Why is this option still given to us?  Why not simply remove this feature?  Is there still any use for this?


Yes of course, VFP designers won't place something useless in our beloved VFP.  Here is a scenario:

* A machine has two printers installed, a POS and a NON-POS one.
* Receipts/Invoices using @ say to be printed to the POS printer
* Rest of the reports on an frx-base, to be printed onto the NON-POS printer

What we normally do in this case is:

* Make the POS printer the default OS printer
* When we need to print onto the NON-POS one, we switch printer via either GETPRINTER() or SET PRINTER TO NAME commands

And that will do the trick!

But then, is that the only way to achieve such? Nope!

One easy way to ensure that the frx-based report will prioritize the NON-POS printer even though the default OS printer is the POS one, is to open the frx intended for the non-POS printer, change the printer inside its page setup to that NON-POS, then save printer environment.

What will happen when we the printer environment is stored onto the report, among other things, is it will now prioritize that NON-POS printer even though it is not the default OS printer; as long as printer is connected on the local machine or on the network, automatically.  Without us redirecting report to another printer via that SET PRINTER TO NAME or GETPRINTER() commands.

I hope this gives you some further ideas of this Save Printer Environment feature.

No comments:

Post a Comment