Page 1 of 2

Printing double sided

PostPosted: Mon Oct 03, 2022 9:54 pm
by dtussman
Is there some command to force a printer to print single-sided? I see there's a command prnduplex() but can't find any documentation.

Re: Printing double sided

PostPosted: Tue Oct 04, 2022 8:20 am
by Enrico Maria Giordano
Try this:

Code: Select all  Expand view
PRNDUPLEX( nValue )


where nValue is one of these:

Code: Select all  Expand view
/* duplex enable */
#define DMDUP_SIMPLEX    1
#define DMDUP_VERTICAL   2
#define DMDUP_HORIZONTAL 3


Reference:

https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-devmodea

Re: Printing double sided

PostPosted: Tue Oct 04, 2022 2:43 pm
by karinha

Re: Printing double sided

PostPosted: Tue Oct 04, 2022 5:31 pm
by dtussman
Thanks, but how would you restore printing to single sided? It seems that with MAC computers the default is double sided, o r if someones printer is set to double sided and I want to switch to single sided how would i do it? Would prnduplex(0) work?

Re: Printing double sided

PostPosted: Tue Oct 04, 2022 5:38 pm
by Enrico Maria Giordano
No, it should be this:

Code: Select all  Expand view
PRNDUPLEX( DMDUP_SIMPLEX )


Code: Select all  Expand view
DMDUP_SIMPLEX   Normal (nonduplex) printing.

Re: Printing double sided

PostPosted: Tue Oct 04, 2022 5:51 pm
by TimStone
All my printing is always single-sided and I would love to have double-sided as an option. Yes, my printer supports it.

I see the objective here is to push single sided, but what if I wanted it to be double sided ?

Thanks.

Re: Printing double sided

PostPosted: Tue Oct 04, 2022 6:11 pm
by dtussman
OK but DMDUP_SIMPLEX is a variable that does not exist. I would suspect it represents a numeric value and perhaps that is 0???

Re: Printing double sided

PostPosted: Tue Oct 04, 2022 7:18 pm
by Enrico Maria Giordano
Please, both of you, carefully reread my first message! There is all you need.

Re: Printing double sided

PostPosted: Tue Oct 04, 2022 8:42 pm
by dtussman
Got it! thanks Enrico. My brain cells were not all firing I guess.

Re: Printing double sided

PostPosted: Tue Oct 04, 2022 8:51 pm
by Enrico Maria Giordano
:D

Re: Printing double sided

PostPosted: Wed Oct 05, 2022 10:16 pm
by TimStone
I've had two recent eye surgeries, and didn't have corrective lenses ( to see the text clearly ) until today.

Re-reading this, and the reference page, I would do the following:

Single Sided =. PrnDuplex( 1 )
Dual sided, Landscape = PrnDuplex( 3 )
Dual sided, Portrait = PrnDuplex( 2 )

Now ... If my printer defaults to Single Sided, and I select Duplex for a print job, do I need to issue the command to return to simplex at the end of a job, or will it automatically default back ?

Re: Printing double sided

PostPosted: Thu Oct 06, 2022 7:50 am
by Enrico Maria Giordano
I don't know. Please try and let us know.

Re: Printing double sided

PostPosted: Tue Oct 25, 2022 12:46 am
by TimStone
Sorry for the delay. I finally had the chance to test this. Here is what I have found:

1) I can use PRNDUPLEX( 1 ) to set the printer to one side only

2) I can use PRNDUPLEX( 2 ) or ( 3 ) to print both sides ( duplex ). HOWEVER, it prints incorrectly. Either 2 or 3 will print the same. It is called "short edge binding" and it means that with a single sheet, you rotate it vertically to see the other side properly. (2) should use long edge binding. That means on page one, if you hold the left side and flip the page to the left, the back side will have the print top at the same top of the sheet as the front.

3) I also find if I send it to the printer from the View mode, it works. If I send it directly to the printer, it does not work. In other words, in the print selection dialog, FROM USER needs to be selected, and just sending to the default printer does not trigger duplex printing.

We have no provision for passing this value in the tPrinter class. We can pass mode ( portrait or landscape ), number of copies, and more, but we cannot pass the Duplex setting. Since all of my reports are built with the tPrinter class, this would be a very useful addition. I think this would solve the issue in #3 above.

I DID FURTHER RESEARCH:
Here is the PRNDUPLEX code from FW:
Code: Select all  Expand view
HB_FUNC( PRNDUPLEX ) // ( nValue ) --> nOldValue
{
   LPDEVMODE  lpDevMode;
   int dmDuplex;

   PrinterInit();

   lpDevMode  = (LPDEVMODE) GlobalLock( pd.hDevMode );

   dmDuplex = lpDevMode->dmDuplex;

   if( hb_pcount() > 0 )
      lpDevMode->dmDuplex = hb_parni( 1 );

   hb_retni( dmDuplex );
   GlobalUnlock( pd.hDevMode );
}

 

Note that is does not take the value passed. So apparently the command defaults to "short side binding". I'm not sure who would use that one (3). We need to use long edge binding ( 2 ).

Yes, it would be nice to see this incorporated, with proper options, in the tPrinter class ( printer.prg )

Antonio ????

Re: Printing double sided

PostPosted: Tue Oct 25, 2022 7:22 am
by Antonio Linares
Dear Tim,

Checking it with Mr. Rao

many thanks for your feedback

Re: Printing double sided

PostPosted: Tue Oct 25, 2022 7:28 am
by Enrico Maria Giordano
TimStone wrote:Note that is does not take the value passed.


Yes, it does:

Code: Select all  Expand view
lpDevMode->dmDuplex = hb_parni( 1 );


Or am I missing something?