Skip to main content

We have a form in our software that prints on an 6 x 12 sheet of paper.   When you select that paper size in the Windows Printer Defaults pop-up box, how do I get that information to my program??  Right now it still prints as the 8 1/2 x 11 default.

Is there something I set before I call "PC_PRINTER_INFO_DOTNET"?

I should also note that I can't hard code anything in here specifically for the 6 x 12 because this code is in a print copybook that ALL of our programs that print use.

This is my code:

               declare status-code as binary-long.
               declare testdelegate  as type PrinterInfoDelegate.
               set testdelegate to
                      delegate(gr as type Graphics,
                                       pb as type Rectangle,
                                       ps as type PageSettings,
                                       uo as object)

            end-delegate.
             call "PC_PRINTER_INFO_DOTNET" using by reference PRINTER-HANDLE
                                                                                           by value testdelegate
                                                                                           by value "TestText"
                                                                             returning status-code.

We have a form in our software that prints on an 6 x 12 sheet of paper.   When you select that paper size in the Windows Printer Defaults pop-up box, how do I get that information to my program??  Right now it still prints as the 8 1/2 x 11 default.

Is there something I set before I call "PC_PRINTER_INFO_DOTNET"?

I should also note that I can't hard code anything in here specifically for the 6 x 12 because this code is in a print copybook that ALL of our programs that print use.

This is my code:

               declare status-code as binary-long.
               declare testdelegate  as type PrinterInfoDelegate.
               set testdelegate to
                      delegate(gr as type Graphics,
                                       pb as type Rectangle,
                                       ps as type PageSettings,
                                       uo as object)

            end-delegate.
             call "PC_PRINTER_INFO_DOTNET" using by reference PRINTER-HANDLE
                                                                                           by value testdelegate
                                                                                           by value "TestText"
                                                                             returning status-code.

How are you selecting the printer and changing the properties? Are you doing this in the Printer Dialog box displayed during PC_PRINTER_OPEN?

When I change the properties there they are automatically set when using PC_PRINTER_WRITE. I can change the paper size and landcape mode and that is the way it will print.

I am testing with VC 7.0.


How are you selecting the printer and changing the properties? Are you doing this in the Printer Dialog box displayed during PC_PRINTER_OPEN?

When I change the properties there they are automatically set when using PC_PRINTER_WRITE. I can change the paper size and landcape mode and that is the way it will print.

I am testing with VC 7.0.

I am using the PC_PRINTER_OPEN, and when the Windows Printer Box Appears, I am selecting Properties, and choosing the paper size there.


How are you selecting the printer and changing the properties? Are you doing this in the Printer Dialog box displayed during PC_PRINTER_OPEN?

When I change the properties there they are automatically set when using PC_PRINTER_WRITE. I can change the paper size and landcape mode and that is the way it will print.

I am testing with VC 7.0.

PC_PRINTER_SET_DEFAULT is what opens the Windows Printer Box when you pass a 2 in the defaults option.  Is there something that gets passed back from there that sets the paper size (length and width)


PC_PRINTER_SET_DEFAULT is what opens the Windows Printer Box when you pass a 2 in the defaults option.  Is there something that gets passed back from there that sets the paper size (length and width)

PC_PRINTER_SET_DEFAULT with an option of 2 will only return the selected printer to the program. It doesn't actually set the printer as the default unless you follow it with a second call using the option of 1.

Changing the property in the PC_PRINTER_OPEN dialog should automatically set the printer to the new size if it is a valid selection for that printer. This works for me.

Have you tried any of the other settings such as landscape orientation to see if this is just a problem with the papersize property or a general problem with setting all properties?

PC_PRINTER_DEFAULT_PROPERTIES can also be called to change these properties programmatically before the PC_PRINTER_OPEN call is made.


PC_PRINTER_SET_DEFAULT with an option of 2 will only return the selected printer to the program. It doesn't actually set the printer as the default unless you follow it with a second call using the option of 1.

Changing the property in the PC_PRINTER_OPEN dialog should automatically set the printer to the new size if it is a valid selection for that printer. This works for me.

Have you tried any of the other settings such as landscape orientation to see if this is just a problem with the papersize property or a general problem with setting all properties?

PC_PRINTER_DEFAULT_PROPERTIES can also be called to change these properties programmatically before the PC_PRINTER_OPEN call is made.

Our programs are hardcoded to print either portrait or landscape depending on what type of form or report we are printing. That is set with PC_PRINTER_DEFAULT_PROPERTIES after the printer is open.

I guess I need to know how the properties are passed back to the program so I can make sure it is set. 


Our programs are hardcoded to print either portrait or landscape depending on what type of form or report we are printing. That is set with PC_PRINTER_DEFAULT_PROPERTIES after the printer is open.

I guess I need to know how the properties are passed back to the program so I can make sure it is set. 

We are also using PC_PRINTER_INFO_DOTNET after we open the Printer, could this have something do do with it??

Here is the code

           declare status-code as binary-long.
           declare testdelegate  as type PrinterInfoDelegate.
           set testdelegate to method MyPrinterInfo.
           call "PC_PRINTER_INFO_DOTNET" using by reference PRINTER-HANDLE
                                               by value testdelegate
                                               by value "TestText"
                                     returning status-code.

And then here is the Method for MyPrinterInfo.

       method-id MyPrinterInfo.
       procedure division using by value gr as type Graphics
                                by value pb as type Rectangle
                                by value ps as type PageSettings
                                by value uo as object.

       end method.

PrinterInfoDelegate is defined this way:

       delegate-id PrinterInfoDelegate.
       procedure division using by value gr as type Graphics
                                by value pb as type Rectangle
                                by value ps as type PageSettings
                                by value uo as object.
       end delegate.


We are also using PC_PRINTER_INFO_DOTNET after we open the Printer, could this have something do do with it??

Here is the code

           declare status-code as binary-long.
           declare testdelegate  as type PrinterInfoDelegate.
           set testdelegate to method MyPrinterInfo.
           call "PC_PRINTER_INFO_DOTNET" using by reference PRINTER-HANDLE
                                               by value testdelegate
                                               by value "TestText"
                                     returning status-code.

And then here is the Method for MyPrinterInfo.

       method-id MyPrinterInfo.
       procedure division using by value gr as type Graphics
                                by value pb as type Rectangle
                                by value ps as type PageSettings
                                by value uo as object.

       end method.

PrinterInfoDelegate is defined this way:

       delegate-id PrinterInfoDelegate.
       procedure division using by value gr as type Graphics
                                by value pb as type Rectangle
                                by value ps as type PageSettings
                                by value uo as object.
       end delegate.

Using PC_PRINTER_INFO_DOTNET shouldn't affect it at all.

Could you please try for a test to compile and run the simple test program below?

When the Dialog Box is displayed change the orientation to landscape and choose a different paper size.

Does this program also fail or does it work?

       program-id. pcid. 
       working-storage section.
       01. 
          03 document-title. 
             05 title-len         pic x(2) comp-5. 
             05 title-text        pic x(20). 
          03  font-family. 
             05 font-family-namelen  pic x(2) comp-5 value 80. 
             05 font-family-name     pic x(80). 
          03 abort               pic x(4) comp-5 value 1. 
          03 ctrl                pic x(4) comp-5 value 2. 
          03 flags               pic x(4) comp-5 value 1. 
          03 handle              pic x(4) comp-5. 
       01 status-code            pic x(4) comp-5 value zeroes. 
       01 buffer                 pic x(20)   value "this is test".
       procedure division. 
       
           move 30 to title-len 
           
           move 1 to flags
           call "PC_PRINTER_OPEN" using by reference handle
                                           by reference document-title 
                                           by value flags 
                                           by value 0 
                                           returning status-code 
           end-call 
           if status-code not equal 0 
               exhibit named status-code 
               stop run 
           end-if 
         
           call "PC_PRINTER_WRITE"
               using by reference handle
                     by reference buffer
                     by value     length of buffer
               returning          status-code
           end-call

           call "PC_PRINTER_CLOSE" using
               by reference handle 
               returning status-code 
           end-call 
           if status-code not equal 0 
               exhibit named status-code 
               stop run 
           end-if 
           goback. 
       end program. 
 


Using PC_PRINTER_INFO_DOTNET shouldn't affect it at all.

Could you please try for a test to compile and run the simple test program below?

When the Dialog Box is displayed change the orientation to landscape and choose a different paper size.

Does this program also fail or does it work?

       program-id. pcid. 
       working-storage section.
       01. 
          03 document-title. 
             05 title-len         pic x(2) comp-5. 
             05 title-text        pic x(20). 
          03  font-family. 
             05 font-family-namelen  pic x(2) comp-5 value 80. 
             05 font-family-name     pic x(80). 
          03 abort               pic x(4) comp-5 value 1. 
          03 ctrl                pic x(4) comp-5 value 2. 
          03 flags               pic x(4) comp-5 value 1. 
          03 handle              pic x(4) comp-5. 
       01 status-code            pic x(4) comp-5 value zeroes. 
       01 buffer                 pic x(20)   value "this is test".
       procedure division. 
       
           move 30 to title-len 
           
           move 1 to flags
           call "PC_PRINTER_OPEN" using by reference handle
                                           by reference document-title 
                                           by value flags 
                                           by value 0 
                                           returning status-code 
           end-call 
           if status-code not equal 0 
               exhibit named status-code 
               stop run 
           end-if 
         
           call "PC_PRINTER_WRITE"
               using by reference handle
                     by reference buffer
                     by value     length of buffer
               returning          status-code
           end-call

           call "PC_PRINTER_CLOSE" using
               by reference handle 
               returning status-code 
           end-call 
           if status-code not equal 0 
               exhibit named status-code 
               stop run 
           end-if 
           goback. 
       end program. 
 

Well - I was mistaken on how our program works. We do not use the PC_PRINTER_OPEN command.  Our printer is setup as if it were a file, with an Select statement and an FD.

So before we open the printer, we set the orientation of the printer, by calling PC_PRINTER_DEFAULT_PROPERTIES, and then we call PC_PRINTER_SET_DEFAULT to select the printer, and the parameters.

Then the printer is opened, and then we call the PC_PRINTER_INFO_DOTNET.

Shouldn't we be sending something through with the PC_PRINTER_INFO_DOTNET to tell the printer the paper size has changed?