# LPD Printing



## daringturtle (May 13, 2009)

Ok, I need help setting up my printer.  I'm giving up on cups and apsfilter.  For now i'm trying to just print with my hp all-in-one officejet using LPD.  The method I tried is the one outlined by "oko" in a previous thread "setting up usb printer".  Here is what I did, not neccesarily in this order.


```
#cd /usr/ports/print/ghostscript8
#make install clean
```
I believe this is the driver?

```
#cd /usr/ports/print/hpijs
#make install clean
```
I believe the driver might use this?

```
#cd /usr/ports/print/foomatic-filters
#make install clean
```
I believe this is the input filter for something(LPD)?
I down loaded ppd file from linuxprinting website to:

```
/etc/ppd/HP-OfficeJet_6200-hpijs.ppd
```
I added to /etc/printcap

```
lp|hp6200|HP_OfficeJet_6200:\
        :lp=/dev/ulpt0:\
        :af=/etc/ppd/HP-OfficeJet_6200-hpijs.ppd:\
        :if=/usr/local/bin/foomatic-rip:\
        :sh:sd=/var/spool/output:\
        :lf=/var/log/lpd-errs:
```
I added to /etc/rc.conf

```
lpd_enable="YES"
```
I added to /etc/devfs.conf

```
perm /dev/ulpt0 0664
```
I edited this line in /etc/group

```
daemon:*:1:daemon,root
```

Then i rebooted and tried to print a directory list with:

```
ls | lpr
```
My printer spit out a page with this line at top:

```
)  HP-PCL XL;1;1;Comment  --then a copyright and some wierd characters
```
I also tried to print something from KDE with this error:

```
A print error occured. Error message received from system:
/usr/local/bin/lpr -P 'lp' '-#1' '/tmp/kde-root/kdeprint_7JEAhjU7'
execution failed with message:
/usr/local/bin/lpr: connection refused
```

Can anyone shed some light on where I went wrong or right,troubleshooting methods or files?
I'm hoping to learn more about the entire printing process. i'm a freebsd and unix newb so obvious to someone else may be a roadblock to me.  I've been trying to get this printer to work for a couple of months now and am determined to succeed. I read the chapter on printing in the freebsd handbook, which was helpful,  and some other docs but now i'm stuck. Any help would be appreciated.

Thanks,
Daringturtle


----------



## Oko (May 13, 2009)

You have a permission problem 

```
daemon:*:1:daemon,root
```
means that only root can print. Add your regular user name and you should be good to go.


----------



## daringturtle (May 13, 2009)

thx oko,

I was printing as root.   I added to /etc/group anyway

```
daemon:*:1:daemon,root,barnstormer
```
Still no response from printer.
The job does appear under the print queue (lpq) for a short period then goes away.  Should I add "wheel" group to permission list daemon?

Any trouble shooting tips?

thanks again,
daringturtle


----------



## daringturtle (May 13, 2009)

*Print log file*

OK,

here is a copy of one of the print log files, I'm trying to make heads or tails out of it.  Anyone shed some light?

thanks 
daringturtle 


```
djb# cat /var/log/lpd-errs
May 11 13:05:19 djb newsyslog[746]: logfile first created
May 12 14:45:05 djb lpd[870]: lpd startup: logging=0
foomatic-rip version $Revision: 3.43.2.6 $ running...
called with arguments: '-w132', '-l66', '-i0', '-n', 'root', '-h', 'djb.domain.actdsltmp', '/etc/ppd/HP-OfficeJet_6200-hpijs.ppd'
Parsing PPD file ...
*cupsFilter: "application/vnd.cups-postscript 100 foomatic-rip"
*cupsFilter: "application/vnd.cups-pdf 0 foomatic-rip"
*cupsFilter: "application/vnd.apple-pdf 25 foomatic-rip"
Added option ColorSpace
Added option Resolution
Added option PageSize
Added option PageRegion
Added option Model
Added option PrintoutMode
Added option InputSlot
Added option ImageableArea
Added option PaperDimension
Added option Duplex
Added option Quality
Added option Font

Parameter Summary
-----------------

Spooler: lpd
Printer:
PPD file: /etc/ppd/HP-OfficeJet_6200-hpijs.ppd
Printer model: HP OfficeJet 6200 Foomatic/hpijs (recommended)
Options:
Job title:
File(s) to be printed:
<STDIN>


================================================

File: <STDIN>

================================================

Reading PostScript input ...

Job does not start with "%!", is it PostScript?
Starting file converter

Starting converter for non-PostScript files
file converter PID kid2=1151
file converter command: echo "Cannot convert file to PostScript!" 1>&2
tail process done reading data from STDIN
KID2 finished
Cannot convert file to PostScript!

Job does not start with "%!", is it PostScript?
Starting file converter
Process dying with "File conversion filter probably crashed", exit stat: 3
File conversion filter probably crashed
May 12 14:52:03 djb lpd[1148]: lp: filter 'f' exited (retcode=3)
May 12 14:52:46 djb lpd[1148]: mail sent to user root about job <unknown> on printer lp (FILTERERR)
```

An error with the filter? Does filter need to be setup?  Should i also install "foomatic-db", "foomatic-db-engine", "foomatic-db-hpijs"?
Any insight?
Thanks again
daringturtle


----------



## Oko (May 13, 2009)

No, you didn't make any mistake. Your set up looks correct. What
kind of file are you trying to send to the printer?

What happens when you try to print from the command line?
Open the shell and send PostScript file with the command


```
lpr -Pprintername my_file.ps
```

This starts to look like a KDE problem to me or you are missing some conversion filter. I assume that printer is locally attached right?

The only other thing I can think of is that you are sending wrong paper size.
If you are outside of US go through your PPD file and make sure the paper
size reads A4. If you live in US it must be Letter.


----------



## daringturtle (May 14, 2009)

OK, I got the printer to print a small PS file ( the example from FreeBSD handbook 9.3.1.4) with

```
lpr filename
```
also with

```
lpr -Php6200 filename
```

My printer is locally attached with a usb cable. Another file i tried to print from shell command line, was the lptest program which i tried to print unsuccesfully several different ways.


```
#lptest > /dev/ulpt0
       or
#/usr/sbin/lptest > /dev/ulpt0
     ---this spit out 3 pages with one line at the top one with all the characters on the top line
#lpr /usr/sbin/lptest
     ---this spit out one blank page
#cat /usr/sbin/lptest > /dev/ulpt0
     ---spit out many pages with a couple wierd symbols at top
```

From the PPD file it looked like letter was the default paper size.  I have a feeling a problem may lie in the conversion filters.  i get this mail message after unsuccessful print attempts. (partial)

```
===============================================

File: <STDIN>

================================================

Reading PostScript input ...

Job does not start with "%!", is it PostScript?
Starting file converter

Starting converter for non-PostScript files
file converter PID kid2=14122
file converter command: a2ps -1 --medium=Letterdj  -o -
tail process done reading data from STDIN
KID2 finished
[stdin (binary): ignored]
[No output produced]

Job does not start with "%!", is it PostScript?
Starting file converter
Process dying with "File conversion filter probably crashed", exit stat: 3
File conversion filter probably crashed
```
with a slight difference before i installed a2ps-letter(port)
on the file converter command line:

```
Starting converter for non-PostScript files
file converter PID kid2=1151
file converter command: echo "Cannot convert file to PostScript!" 1>&2
tail process done reading data from STDIN
KID2 finished
Cannot convert file to PostScript!
```

The PPD file also says foomatic 4.0 is necessary and i have "foomatic-filters 3.0.2_4 Foomatic wrapper scripts" i'm not sure if this is part of foomatic 4 or not.  Does any of this help narrow down the issue?

Thanks daringturtle


----------



## Oko (May 14, 2009)

Looks like problem with conversion filter to me. I asked you to post what kind of file you are trying to send from KDE. All files gets converted to PostScript before printing. Foomatic-rip is Perl script which magically guesses the type of file you are sending to printer and calls appropriate filter. For instance if I send PDF file foomatic rip will parse first couple lines and conclude that is PDF. Than it will run command pdf2ps which is actually conversion filter which in turn is the part of Ghostscript package. You can avoid all that by running your files through appropriate filters by hand. Most common are dvips, pdf2ps, ensript, a2ps and for all kind of image files ImageMagic packet. 

I would guess that you do not have problem with foomatic-rip.

It is also very possible that you have problem with KDE as it expects CUP not LPD. For instance in order to print from Firefox I had to add lpr in 


```
$ more .gtkrc-2.0 
gtk-print-backends = "file,lpr,cups"
```


----------



## daringturtle (May 15, 2009)

From kde i'm trying to print .pdf , .tif , .doc files for now. I was glad to print a simple PostScript file from the freebsd command shell but couldn't get anything else to print from there.  How would i print something simple, like say a directory list, from command prompt? i tried several other suggestions with no success.  Getting that to work first seems like the next best step, to me.

thanks again oko
daringturtle


----------



## Oko (May 15, 2009)

daringturtle said:
			
		

> From kde i'm trying to print .pdf , .tif , .doc files for now. I was glad to print a simple PostScript file from the freebsd command shell but couldn't get anything else to print from there.  How would i print something simple, like say a directory list, from command prompt? i tried several other suggestions with no success.  Getting that to work first seems like the next best step, to me.
> 
> thanks again oko
> daringturtle



Since you mentioned .doc files I assume you are using something like OpenOffice, KOffice, or Abiword. All those programs have option save as when you can essentially pipe file through built in filter into PostScript file. Such file can be printed without any filter with lpr  filename.ps.

ImageMagic will take care of .tif image format. Convert file as follows. I would guess that OpenOffice or KOffice can pipe tif image files into PS as well. To use ImageMagic open the shell

```
convert imagefile.tif imagefile.ps
```
Then just print with lpr. 

You have a problem with application filters and printer set up in applications. You do not have problem with LPD spooling system.

Above behavior is not normal. I can print anything I like out of my applications on my OpenBSD desktop just like you would do it in Windows, Linux, or Solaris without printing first to PostScript files. 

You should ask about your problem on FreeBSD/KDE mailing list.They should be able to help you.


----------



## daringturtle (May 21, 2009)

Thanks oko helpful post.  I finally got something to print.  I printed several different ways.  First i printed the lptest program with:

```
lptest | lpr
```
still had a header and border with "stdin" at top eventhough i had :sh: (supress header) in printcap file. 

then my real success came when i realized i could print(essentially pipe) to a file as a converted postscipt file from kde printing utility.  then i printed from freebsd command line with:

```
lpr filename.ps
```
Still couldn't print .pdf or .tif files.  When i tried the printer wanted to spew out over a hundred pages of code or gibberish.  Haven't tried imagemagic yet but i think it will work for the .pdf and .tif files.  I'm not concerned with that for now.  I can print my work orders for my job now which is what i needed.  The rest, like printing straight from kde, i can figure out over time.  

Thanks again oko, a real help,
darinturtle


----------



## Oko (May 22, 2009)

daringturtle said:
			
		

> Still couldn't print .pdf




```
pdf2ps filename.pdf filename.ps
lpr filename.ps
```


----------

