# Duplex printing with lp/lpr

## d135-1r43

I use a Samsung CPL500N laser printer together with cups. The printer is able to print in duplex mode. I can use the duplex function together with 'llpr' which is a nice gui program where I can click on 'duplex' and everything works fine. 

But now I need the non-gui solution for my scripts. Are there any options for lp or lpr to configure the duplex mode? I've nothing found in the man pages.

----------

## Headrush

Look through the ppd file for you printer and find the option that enables duplex printing.

Once you do that you should be able to manually pass the option to lp.

----------

## d135-1r43

Okay, I've found the corresponding file but I've no idea what I should look for. 

These are the lines that probably have something to do with the duplex function:

```
[...]

*% ++++++++++++++

*%  Duplex Mode

*% ++++++++++++++

*OpenUI *Duplex/Duplex:  PickOne

*OrderDependency: 50 AnySetup *Duplex

*DefaultDuplex: None

*Duplex None/None: " <</Duplex false>> setpagedevice"

*Duplex DuplexNoTumble/Long Edge: "

    <</Duplex true /Tumble false>> setpagedevice"

*End

*Duplex DuplexTumble/Short Edge: "

    <</Duplex true /Tumble true>> setpagedevice"

*End

*?Duplex: "

   save

      currentpagedevice /Duplex get

        {currentpagedevice /Tumble get

            {(DuplexTumble)}{(DuplexNoTumble)}ifelse

         }{(None)} ifelse = flush

   restore

"

*End

*CloseUI: *Duplex

[...]
```

----------

## Headrush

The easiest way to be 100% sure, is turning on debugging for cups, print a duplex page using your GUI and then check the cups log to see the options it sends.

The reason I say this is it looks like it might send two options to cups: one to enable duplex printing and the second to specify how to flip the back page.

----------

## stringbean

An alternative is to do what they did in my old University and have two different printer names, one for duplex and one for normal. This way you don't need to fiddle with printer options as they would be set by CUPS as the default for that printer, instead you just print to the right printer.

eg:

cpl500n - single sided instance

cpl500n_duplex - duplexed instance

So if you wanted duplex printer you would use:

lpr -Pcpl500n_duplex

(This is assuming that you are using CUPS or something similar of course).

----------

## d135-1r43

I've found the right options in the logs of CUPS after I've enabled advanced debugging. For documentation:

```
lp -o "Duplex=DuplexNoTumble sides=two-sided-long-edge Collate" file.pdf
```

Thanks for the help!

----------

## Headrush

 *d135-1r43 wrote:*   

> I've found the right options in the logs of CUPS after I've enabled advanced debugging. For documentation:
> 
> ```
> lp -o "Duplex=DuplexNoTumble sides=two-sided-long-edge Collate" file.pdf
> ```
> ...

 

Great.

Anyone interested, stringbean's option would work too and it's what I use to make it easier for users to chose color and/or black/white on my network printer.

----------

