# Printing from OpenOffice with lpd



## free-and-bsd (Jun 28, 2013)

There's one thing I can't find: how to use lpd to print from programs like OpenOffice. Is it possible at all, or should I print to a file and then print the file from command line using lpd?


----------



## wblock@ (Jun 28, 2013)

It used to be possible in OpenOffice and LibreOffice. _It h_ad to be set up in the Tools/Options/Print menu.  Later versions seem to not support the classic lpd(8) any more, or at least make setting it up non-obvious.

A workaround is to export the file as PDF, then print it with graphics/xpdf.


----------



## free-and-bsd (Jul 2, 2013)

The last time I checked it was with LibreOffice-3.5.7 installed via pkg_add, so in this packaged version the spadmin program is broken and fails to start with this message:
	
	



```
No printers can be installed, because the file system is read-only. Please contact your system administrator.
```
 Which has its bug report here.

The remedy reported to work is to rebuild editors/libreoffice with CUPS support enabled. Never gone this far with LibreOffice, thought it would take forever to build. But the idea of using lpd is so intriguing. So I'll try and report back about the success with editors/libreoffice rebuilt and whether this will make spadmin start normally without starting cupsd.

In the meantime, I will see if I can make my present lpd setup work. At present my /etc/printcap looks like this:
	
	



```
samsung|Samsung ML-2850 PostScript printer:\
	:sh:sd=/var/spool/output/lpd:\
	:lp=/dev/ulpt0:\
	:af=/etc/print/Samsung-ML-2850D-Postscript.ppd:\
	:if=/usr/local/bin/foomatic-rip:\
	:lf=/var/log/lpd-errs:\
	:rg=print:\
	:rs=true:
```
In which /dev/ulpt0 is the USB device created when the printer is ON (yes, it's locally connected via USB port). It responds well to the `lptest` command. Then /etc/print/Samsung-ML-2850D-Postscript.ppd is the PPD file for this model of printer, which works with foomatic-rip on Linux, Solaris and FreeBSD CUPS configuration.

Now `lptest > /dev/ulpt0` works more or less: it prints a succession of printable characters, though processing three sheets of paper and only printing on the last one. But when trying the whole setup with `printf â€œThis is a test\r\n\fâ€ | lpr`, I get:
	
	



```
lpr: lp: unknown printer
```
 My lpr is /usr/bin/lpr.


----------



## free-and-bsd (Jul 2, 2013)

OK, trying with `lptest 20 5 | lpr -Psamsung` I get:
	
	



```
lpr: Restricted group specified incorrectly
```

And how do I determine the correct one? The /dev/ulpt0 is owned by root:cups (comes from /etc/devfs.rules for CUPS setup), while the spool by root:daemon.


----------



## free-and-bsd (Jul 2, 2013)

Changed rg:print: to rg:cups: in /etc/printcap. Now `lptest 20 5 | lpr -Psamsung` gives no error, yet the printer doesn't respond.


----------



## wblock@ (Jul 2, 2013)

CUPS and the real lpr(1)/lpd(8) don't mix well.  /usr/bin/lpr is the real one.  CUPS had the great idea of using the same filename, but since it is installed from a port, it is in /usr/local/bin/lpr.  Unless you have told it to overwrite the base one...  If both are installed, you get the first one on the path, unless you type in a full path.

Anyway, CUPS filters seem to expect things to be set up for CUPS, and the ones I've looked at don't like that missing environment when run with the real lpr(1).  So that may be another problem.

Why are you using the rg and rs properties in printcap?  Suggested setup here: lpd Printing With FreeBSD.

The newest LibreOffice appears to want/expect CUPS, period.  It will go through the motions of printing to a file, but no file is created.  The right thing to do would be search LibreOffice bug reports for ones involving the real lpr(1).  That could be complicated by the stupid name choice made by the CUPS people.  If no such bug report exists, it should be added.


----------



## free-and-bsd (Jul 2, 2013)

So it prints finally from Firefox using "Print to LPR" using a simple `lpr` command. What I did is modifying the first line in /etc/printcap to look like this:
	
	



```
[B]lp[/B]|samsung|...
```
Adding "lp", default printer name, solved this.

Only, I can't yet make it use printer's duplex, as `-Z duplex` added to `lpr`doesn't work.


----------



## free-and-bsd (Jul 2, 2013)

wblock@ said:
			
		

> CUPS and the real lpr(1)/lpd(8) don't mix well.  /usr/bin/lpr is the real one.  CUPS had the great idea of using the same filename, but since it is installed from a port, it is in /usr/local/bin/lpr.  Unless you have told it to overwrite the base one...  If both are installed, you get the first one on the path, unless you type in a full path.


Well, at least `which lpr` gives me /usr/bin/lpr and there is also /usr/local/bin/lpr...





> ...
> Why are you using the rg and rs properties in printcap?  Suggested setup here: lpd Printing With FreeBSD.


Found that at OpenPrinting web-page. Didn't think it was for CUPS, because with CUPS the setup is pretty straightforward and doesn't need editing /etc/printcap at all





> The newest LibreOffice appears to want/expect CUPS, period.  It will go through the motions of printing to a file, but no file is created.  The right thing to do would be search LibreOffice bug reports for ones involving the real lpr(1).  That could be complicated by the stupid name choice made by the CUPS people.  If no such bug report exists, it should be added.


Yes, so they say there if you rebuild it with CUPS _enabled_ (which by default is _not so_ in the FreeBSD-9.1 package), then spadmin starts well even with cupsd daemon not running. This one I'll check once my build finishes.


----------



## free-and-bsd (Jul 2, 2013)

Checked printing from Firefox supplying /usr/bin/lpr -- still prints OK, but only one side. From monitoring by `tail -f /var/log/lpd-errs` I can see that it uses foomatic. Tried disabling foomatic stuff in /etc/printcap and it works the same, as your manual says Firefox provides PostScript-formatted output. And my printer is a PostScript one.


----------



## free-and-bsd (Jul 2, 2013)

Done building libreoffice with CUPS support added, still spadmin doesn't start with cupsd disabled. OK, forget about it.


----------

