Printing double sided

Post Reply
dtussman
Posts: 102
Joined: Sat Jun 06, 2015 6:57 pm

Printing double sided

Post 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.
User avatar
Enrico Maria Giordano
Posts: 8734
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Been thanked: 1 time
Contact:

Re: Printing double sided

Post by Enrico Maria Giordano »

Try this:

Code: Select all | Expand

PRNDUPLEX( nValue )


where nValue is one of these:

Code: Select all | Expand

/* 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
User avatar
karinha
Posts: 7910
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: Printing double sided

Post by karinha »

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
dtussman
Posts: 102
Joined: Sat Jun 06, 2015 6:57 pm

Re: Printing double sided

Post 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?
User avatar
Enrico Maria Giordano
Posts: 8734
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Been thanked: 1 time
Contact:

Re: Printing double sided

Post by Enrico Maria Giordano »

No, it should be this:

Code: Select all | Expand

PRNDUPLEX( DMDUP_SIMPLEX )


Code: Select all | Expand

DMDUP_SIMPLEX   Normal (nonduplex) printing.
User avatar
TimStone
Posts: 2953
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Has thanked: 25 times
Contact:

Re: Printing double sided

Post 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.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
dtussman
Posts: 102
Joined: Sat Jun 06, 2015 6:57 pm

Re: Printing double sided

Post 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???
User avatar
Enrico Maria Giordano
Posts: 8734
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Been thanked: 1 time
Contact:

Re: Printing double sided

Post by Enrico Maria Giordano »

Please, both of you, carefully reread my first message! There is all you need.
dtussman
Posts: 102
Joined: Sat Jun 06, 2015 6:57 pm

Re: Printing double sided

Post by dtussman »

Got it! thanks Enrico. My brain cells were not all firing I guess.
User avatar
TimStone
Posts: 2953
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Has thanked: 25 times
Contact:

Re: Printing double sided

Post 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 ?
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
Posts: 2953
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Has thanked: 25 times
Contact:

Re: Printing double sided

Post 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

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 ????
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
Antonio Linares
Site Admin
Posts: 42393
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 9 times
Been thanked: 41 times
Contact:

Re: Printing double sided

Post by Antonio Linares »

Dear Tim,

Checking it with Mr. Rao

many thanks for your feedback
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 8734
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Been thanked: 1 time
Contact:

Re: Printing double sided

Post by Enrico Maria Giordano »

TimStone wrote:Note that is does not take the value passed.


Yes, it does:

Code: Select all | Expand

lpDevMode->dmDuplex = hb_parni( 1 );


Or am I missing something?
Post Reply