# Adding page eject on spooler close



## exeter (Jul 1, 2016)

I have set my default printer to a network attached Brother HL-2150N. Irritatingly the end of files is not printed until the page eject button is pressed. How can I add a page eject to the end of the files?

My /etc/printcap looks like this:


```
lp|Brother HL-2150N:lp=:rm=192.169.0.11:rp=brother:sd=/var/spool/brother:if=/usr/local/libexec/lf2crlf:
```

My lf2crlf interface file looks like this:


```
#! /bin/sh
# /usr/local/libexec/ls2crlf
CR=$'\r'
/usr/bin/sed -e "s/$/${CR}/g"
```


----------



## ASX (Jul 1, 2016)

If you don't specify a filter in your printcap, a formfeed will be appended automatically at the end of the job.

Because your filter appear to do only a conversion from LF to LF+CR, I think you could setup your printer to use LF only instead of LF+CR and remove the software filter.

Alternatively you need to use a filter that add a formfeed at the end of the file to print, something like:
ff-filter

```
#!/bin/sh
#
cat
echo -n \\f
```

and use the following filter in printcap:

```
if=/usr/local/libexec/lf2crlf | ff-filter
```
Adjust the ff-filter path as you see fit.

Hope it is correct, many years are past from last time I used lpd.


----------



## exeter (Jul 4, 2016)

ASX said:


> If you don't specify a filter in your printcap, a formfeed will be appended automatically at the end of the job.
> 
> Because your filter appear to do only a conversion from LF to LF+CR, I think you could setup your printer to use LF only instead of LF+CR and remove the software filter.
> 
> ...


Thank you for the suggestion, but `lpd`/`lpr`doesn't like the if= section, I get 
	
	



```
lpd[741]: lp: cannot execv(/usr/local/libexec/lf2crlf | /usr/local/libexec/ff-filter): No such file or directory
```

Perhaps I should try whatever-it-is you use? /etc/printcap mentions apsfilter. Is that a good alternative, apsfilter.org seems to be down?


----------



## ASX (Jul 4, 2016)

I see, lp want a single filter ...  can be work around by creating a new filter which include both

/usr/local/libexec/lf2crlf-ff

```
#!/bin/sh
/usr/local/libexec/lf2crlf | /usr/local/libexec/ff-filter
```

and using if=/usr/local/libexec/lf2crlf-ff in /etc/printcap

Additionally, be sure that the filters have "execute" permissions.

apsfilter ... guess it is a converter from ascii to postscript ... isn't going to work if the printer doesn't support postscript directly.

Let see if the workaound is enough ... else post back.


----------



## wblock@ (Jul 4, 2016)

It would be simpler just to create a single filter that does both.  If sed(1) exits when the input ends, could just copy lf2crlf to a new file and add

```
printf "\f"
```
to the end.


----------



## exeter (Jul 13, 2016)

wblock@ said:


> It would be simpler just to create a single filter that does both.  If sed(1) exits when the input ends, could just copy lf2crlf to a new file and add
> 
> ```
> printf "\f"
> ...


Aha! That did it. /etc/lf2crlf now looks like this:

```
#! /bins/h
# /usr/local/libexec/lf2crlf
# converts carriage return to cr+lf
CR=$'\r'
/usr/bin/sed -e "s/$/${CR}/g"
printf "\f"
```

Thanks all.


----------

