I have a .NET managed code application compiled in Visual COBOL 2.0 which is using the PC_PRINTER_OPEN library call to print a document. When making the call the application is setting the flags parameter to 8 which is supposed to cause it to print in landscape mode instead of portrait but it appears to be ignored and it prints in portrait anyway. What is the problem?
There is a known problem in Visual COBOL when trying to set landscape mode using PC_PRINTER_OPEN in managed code.
The flag will be ignored.
This has been fixed but will not be available until Visual COBOL 2.2.
The problem only exists in managed code as it prints in landscape mode fine in native code.
Also, there is a workaround for the problem by calling PC_PRINTER_SET_DEFAULTS to change the orientation to landcape mode before the PC_PRINTER_OPEN call is done.
This assumes that the printer you are opening in PC_PRINTER_OPEN is the current default printer. If it is not then you can change it to be the default printer by using PC_PRINTER_DEFAULT_NAME.
Example of workaround for setting printer to landcape mode in managed code:
01 printer-handle pic x(4) comp-5.
05 pn-name-length pic x(2) comp-5 value 29.
05 pn-name pic x(100) value "HP Officejet Pro L7500 Series".
01 flags pic x(4) comp-5 value 8.
01 window-handle pic x(4) comp-5 value 0.
01 status-code pic x(4) comp-5.
01 print-buffer pic x(20) value "this is a test".
01 print-buffer-len pic x(4) comp-5 value 20.
01 def-flags pic x(4) comp-5 value 512.
05 cblte-pp-len pic x(2) comp-5.
05 cblte-pp-papersize pic s9(4) comp-5.
05 cblte-pp-paperlength pic s9(4) comp-5.
05 cblte-pp-paperwidth pic s9(4) comp-5.
05 cblte-pp-scale pic s9(4) comp-5.
05 cblte-pp-copies pic s9(4) comp-5.
05 cblte-pp-papertray pic s9(4) comp-5.
05 cblte-pp-printquality pic s9(4) comp-5.
05 cblte-pp-color pic s9(4) comp-5.
05 cblte-pp-duplex pic s9(4) comp-5.
05 cblte-pp-orientation pic s9(4) comp-5 value 2.
05 cblte-pp-yresolution pic s9(4) comp-5.
move length of properties to cblte-pp-len
using by value def-flags
by reference properties
by value flags
by value window-handle
by value print-buffer-len
call "PC_PRINTER_CLOSE" using printer-handle