Quantcast
Channel: Sandstorm's Blog (Home of ssUltimate Library)
Viewing all articles
Browse latest Browse all 160

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

$
0
0
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 printer and non-pos one.
* Receipts/Invoices to be printed to the POS printer
* Rest of the reports to be printed onto the NON-POS printer

What we normally do in this case is:

* Make the non-pos printer the default OS printer
* Switch printer to pos for receipts and invoices 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!  That is where saving of printer environment comes into picture.  So the trick is to open those reports intended to that POS printer, going to its page setup, changing the printer to the POS printer, ticking "Save Printer Environment" checkbox, saving the report and recompiling your app.  So:

* Receipts/Invoices - printer is changed via Page Setup onto the POS printer, Save Printer Environment is ticked
* Rest of reports, Save Printer Environment is not ticked

What is the difference on reports where printer environment is saved and not?

* Save Printer Environment (ticked) - our app will attempt to print onto that POS printer (in this case) "disregarding" the OS default printer.  It does not matter that the default printer is the non-pos printer, it will still try to print first onto the POS printer.  Why attempt and try?  Because when the POS printer is not detected on the local machine, then that is the time it will switch to the current OS default printer and print onto that.

So receipts/invoices in this scenario will always attempt to print onto the POS printer making our app looks smart.

* Save Printer Environment(not ticked) - It will always rely on the OS default printer.  That is the default so that is where it will print.  Unless you used the other tricks of GETPRINTER() or SET PRINTER TO NAME as mentioned above.

So other reports will always use the non-pos printer (default OS printer) which will make our app looks really smart. LOL!

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

Viewing all articles
Browse latest Browse all 160

Trending Articles