Highlighted
Absent Member.
Absent Member.
2309 views

Landscape printing directly under Windows

Jump to solution

Ladies and Gentlemen,

I have used cobconfig.cfg Environment Variable and the output was just OK in a A4 style sheet.

But now I have got to print a report in the landscape style.

Any hints and tips.

Thanks a lot in advance.

Cheers.

Rui Natal

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Landscape printing directly under Windows

Jump to solution

There is a known problem in Visual COBOL when trying to set landscape mode using PC_PRINTER_OPEN in managed code.
It will be ignored.

This has been fixed but will not be available until Visual COBOL 2.2, not 2.1.

The problem only exists in managed code as it prints in landscape mode fine in native code.

Also, I have found 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:

      id division.
      program-id.   testorient.
      working-storage section.
      01 printer-handle pic x(4) comp-5.
      01 document-title.
         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.
      01 properties.
         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.
      procedure division.
           move length of properties to cblte-pp-len
           call "PC_PRINTER_DEFAULT_PROPERTIES"
              using by value def-flags
                    by reference properties
              returning status-code
           end-call
           call "PC_PRINTER_OPEN"
              using printer-handle
                    document-title
                    by value  flags
                    by value  window-handle
              returning status-code
           end-call
           call "PC_PRINTER_WRITE"
              using printer-handle
                    print-buffer
                    by value  print-buffer-len
              returning status-code
           end-call
           call "PC_PRINTER_CLOSE" using printer-handle
                                   returning status-code
           stop run.

View solution in original post

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Landscape printing directly under Windows

Jump to solution

Can you please provide some more detail as to how you are printing and whether this is managed code or native code?

You can look at some of the Printer Library routines in the docs here:

Routines that let you set orientation include:

PC_PRINT_FILE
PC_PRINTER_OPEN
PC_PRINTER_DEFAULT_PROPERTIES

You can change the current default printer using PC_PRINTER_DEFAULT_NAME.

Thanks.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Landscape printing directly under Windows

Jump to solution

We've had a number of problems trying to print in landscape in Visual COBOL. This was brought to the attention of Microfocus support who decided, in their wisdom, that there was a problem in doing so and we've received a note to say that a 'fix' for printing in landscape would be forthcoming in VisCobol 2.1. Unless of course anyone knows different?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Landscape printing directly under Windows

Jump to solution

There is a known problem in Visual COBOL when trying to set landscape mode using PC_PRINTER_OPEN in managed code.
It will be ignored.

This has been fixed but will not be available until Visual COBOL 2.2, not 2.1.

The problem only exists in managed code as it prints in landscape mode fine in native code.

Also, I have found 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:

      id division.
      program-id.   testorient.
      working-storage section.
      01 printer-handle pic x(4) comp-5.
      01 document-title.
         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.
      01 properties.
         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.
      procedure division.
           move length of properties to cblte-pp-len
           call "PC_PRINTER_DEFAULT_PROPERTIES"
              using by value def-flags
                    by reference properties
              returning status-code
           end-call
           call "PC_PRINTER_OPEN"
              using printer-handle
                    document-title
                    by value  flags
                    by value  window-handle
              returning status-code
           end-call
           call "PC_PRINTER_WRITE"
              using printer-handle
                    print-buffer
                    by value  print-buffer-len
              returning status-code
           end-call
           call "PC_PRINTER_CLOSE" using printer-handle
                                   returning status-code
           stop run.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.