# Setting up IP Printer (FBSD 7.2r)



## fuzzynco (Oct 11, 2009)

My system is on 192.168.215.30 and the printer 
is on 192.168.215.29. The print server in the printer
understands HP port 9100, IPP and LPR and SMB print 
protocols. 

I tried to setup LPD/LPR and created the referenced 
directory for the spooling directory, do I need to put 
a port in the rp= tag in /etc/printdef? on Windows XP/SP3 
after defining an IP printer port to printers, 
lpr -P 192.168.215.29  file.txt prints fine?

The LPR print server seems to work and IPP (print test 
page from printer config works fine too).

The printer is a Brother HL-5250-DN monochrome laser.
Its SMB address is //brother/brother. I put its IP
in /etc/hosts, is there another config file to update?

Tests with FBSD lpr do queue print jobs but the daemon 
seems to be waiting for the printer become ready, (it
has its own IP addr and is waiting for work).

Thanks


----------



## fuzzynco (Oct 11, 2009)

*addendum: the print server understands postscript data*

I tested on windows with a postscript data stream
it reported  (see attached image).


----------



## fuzzynco (Oct 11, 2009)

*sigh*

Tried to say postscript.txt was the test stream, test page is the 
resulting print output, etc-printcap is the /etc/printcap entry
for 'brother'.


----------



## jnr (Oct 11, 2009)

I'm not too sure about the default LPD, but I use a networked HL-1850 with CUPS by setting it up for "AppSocket/HP JetDirect" and pointing it at socket://172.16.21.184:9100


----------



## fuzzynco (Oct 12, 2009)

*how do you send data?*

I was able to define the CUPS device as suggested, but 
don't know to put something into its queue?
lpr complains that lpd isn't running?

is there as different tool to to queue a print job
for CUPS? Does something still go into /etc/printcap
or does CUPS bypass that? :q


----------



## fuzzynco (Oct 18, 2009)

*(Resolved)  Mostly by my learning about Unix printing*

I copied bits from two different text filters to 
accomodate both PS and plain text and it seems to be working.

:r It seems my printer is smarter than I am 
if it gets plain text it behaves like an HP laser printer.
if it gets postscript it runs it and prints the results.

Thanks 

```
#!/bin/sh
IFS="" read -r first_line
first_two_chars=`expr "$first_line" : '\(..\)'`
if [ "$first_two_chars" = "%!" ]; then
	#
	# Postscript job just print it
	#
	echo "$first_line" && cat && printf "\004" && exit 0
	exit 2
else 
	# 
	# Plain text tell printer then print it
	#
	printf "\033&k2G" && echo "$first_line" &&  cat  \
		&& printf "\f" \
		&& exit 0
	exit 2
fi
```


----------



## fuzzynco (Oct 19, 2009)

*sigh* the ps part of that didn't work, but I defined a new printer
that has no input filter and sending a PS script to it works 
correctly, (postscript is correctly printed by the print server).

addenda:

I am able to use a2ps to do 2up and duplex printing.
I've got to figure out how to update a2ps's defaults
so it is a aware of the target printer (-P) and 
to always do duplexing. I do find that when  
do duplexing if there is a odd physical page 
left over the print doesn't actually print it
until it gets a form-feed. I've been doing an extra
echo "\f" | lpr  to flush it out. I wondered if there 
was an option to force the last physical page to print 
if the job ended up odd?


----------



## fbroce (Oct 20, 2009)

I am using lpd instead of cups. I was having an extra sheet print (not what you are observing but this worked in my printcap file if you are of a mind to try lpd again:

Enable lpd (in rc.conf) and create the spool directory for the printer in /var/spool/ and then use a simple printcap file like this:

```
okidata|okidata b4300 postscript printer:\
:lp=/dev/ulpt0:sd=/var/spool/output/okidata:lf=/var/log/lpd-errs:ff=:;
```
This setup works fine. I am using the usb connection on the printer so make sure your lp is pointed to the correct device. Also,  note the ff=: at the end of the above line. This eliminates extra form feeds and multiple blank pages with each print job (ff=: is the same as routing ff to dev null).


----------



## fuzzynco (Oct 20, 2009)

I'm using FBSD 7.2r lpr/lpd talking to an ethernet PS printer via its 
emulation of lpd protcol. It says its using PS v3. if I send it plain text 
though it behaves like an HP laser jet printer (PCL and plain text).

nods... my problem is the print server is bufferring the last (odd) 
physical page until it get more work to print. basically the reverse 
of your problem, I need an extra ff to flush the last page out of print 
server's buffer (the back of the odd page). I didn't find any printcap directive
to add an extra ff and wondered if there was a way to get a2ps to send an 
extra 'print blank page' postscript sequence if its 
page (physical page) count was odd. example:
 I printed  /etc/defaults/rc.conf which was 10 virtual pages 2up duplex
(4 pages per physical media) needs 3 real sheets (1-4, 5-8,9-10)).
9-10 is front of physical media 3. it doesn't print 9-10 until it gets a 
form feed for the back (physcial page 4).


----------



## roddierod (Oct 20, 2009)

I have the Brother HL-4040CDN, I use CUPS for network printing. Cups generates a /etc/printcap with the name you give the printer, in my case Brother.

Then when you need to use lpr use Cups lpr,

```
/usr/local/bin/lpr -P Brother
```

For some apps like Opera, I had to remove the space between the -P and Brother to get it to work, not sure why. Once I did this it stopped all my printing headaches.

I do notice that on some GTK/Gnome apps, I have to print at 300dpi or fails to print with memory errors.


----------

