About the PrinterDLL
The PrinterDLL was an experiment at the company I work for, to enable Lotus Notes to print in landscape format. Since there were a couple of suggestions nobody had solved the problem. After a bit of research we figured out that this would get more difficult than expected.
The Microsoft way
The only usable solution at current is a Visual Basic dll example from Microsoft. This dll provides a class that reads the current printer settings and changes the property for the printer orientation. Since this dll is a good example for designing the class, it won’t work on W2k or WinXP without administrative privileges.
The G-Productions way
I took the Microsoft idea as base and designed my own class, and it worked on different operating systems. So I posted at the forum on www.notes.net my solution and after a few days I received lots of emails asking me for a copy. So I put the dll for download at http://home.arcor.de/g-productions site and it seemed the problem was solved. Then people began to mail me about problems with the privileges stuff. There was no possibility to test it on the specified machines (in most cases WinXP was the problem) so other people were on to help me. I thought of continue developing on it….
Current status
The current version of the PrinterDLL is v0.9.5 beta, this means, that it works fine as people reported but has no error handling. This is something more serious because of the different OS you use. Another serious problem is, that it may freeze your system when trying to access more than one instance of the main class provided in the library.
Documentation
There should be something like a user guide, but there isn’t. I will give you in the following a short instruction on how to use this library.
The dll contains 4 functions:
Function GetDefaultPrinterName() as String
This function returns a string containing the name of the default printer installed on the system.
Function SetOrientation(ByVal mOrientation As Integer, ByVal mType as Integer) as Boolean
This function is the important one. It sets the printer orientation to the desired value and returns a boolean for success or failure. The parameters are as following:
- mOrientation should be an integer value between 1-3 where the value selects the technique to use when changing the orientation.
- 1 selects the Visual Basic Printer Object (if you will use the dll for Lotus Notes, selecting this value is maybe a bad option)
- 2 selects API calls. (if you will use the dll for LotusNotes this option is best)
- 3 selects driver control. NOTE: This option is still experimental. You can harm your system if you use this option.
- mType should be an integer value between 1-2. This value sets the desired orientation where
- 1 changes the orientation to portrait (in most cases this is the default value)
- 2 changes the orientation to landscape.
- The function returns false if the desired function failed or true for successfully changing the value.
Function ReSetOrientation() as Boolean
When the printerdll is called to change a print orientation the dll stores the old orientation in order to be able to reset the orientation to the desired value. To reset the orientation to the default value you have to manually call this function. It returns true for success or false for failure.
Function GetOrientation() as Integer
This function returns an Integer value for the current printer orientation. 1 for portrait, 2 for landscape and 0 for not determined.
Function GetPrinterList() as Variant
This function returns an array with the system wide installed printers.
Download:
Installer including runtime:
pcontrol_setup.exe
dll only:
PrinterControl.7z