Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 May 2020 18:55:10 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Victor Sudakov <vas@sibptus.ru>
Cc:        freebsd-questions@freebsd.org, Polytropon <freebsd@edvax.de>
Subject:   Re: Brother HL-L2340D printer and lpd?
Message-ID:  <20200505185510.00b622e3.freebsd@edvax.de>
In-Reply-To: <20200505161952.GA34844@admin.sibptus.ru>
References:  <20200503171259.GA48627@admin.sibptus.ru> <20200505161952.GA34844@admin.sibptus.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 5 May 2020 23:19:52 +0700, Victor Sudakov wrote:
> Victor Sudakov wrote:
> > 
> > I'm trying to use a Brother HL-L2340D printer as a simple networked
> > line printer with lpd. I've successfully used HP and Canon printers like
> > that with a simple printcap like this:
> 
> The story continues with some good news.
> 
> Thanks to much insight and help from Polytropon (off list also), and
> this page:
> https://support.brother.com/g/b/faqend.aspx?c=us&lang=en&prod=hll2340dw_us_eu_as&faqid=faq00100602_000
> 
> I've been able to print PDF files (lpr -P ps mozilla.pdf) 
> on this printer with the following printcap entry:
> 
> ps|Brother HL-L2340D series PostScript:\
>         :sh:\
>         :lp=9100@192.168.1.74:\
>         :if=/usr/local/etc/ps2pcl.sh:\
>         :sd=/var/spool/output/lpd2:lf=/var/log/lpd-errs:
> 
> while the ps2pcl.sh looks like this (thanks again to Polytropon):
> 
> #!/bin/sh
> 
> #/usr/bin/printf "\033&k2G" || exit 2
> /usr/local/bin/gs -q -dBATCH -dNOPAUSE -dPARANOIDSAFER -dSAFER \
>         -sDEVICE=hl1250 -sPAPERSIZE=a4 -r600x600 \
>         -sOutputFile=- - && exit 0
> exit 2
> 
> So GhostScript's "hl1250" driver works wonders, I even see Cyrillic
> text in the printed PDF.

Basically, gs will "raster" any PS input it gets. So whatever
symbols are there, they will work without any further tools,
be it chinese symbols or images or german Umlauts. :-)

Thanks for posting the _solution_ to your problem. Future
readers will now know that gs's filter "hl1250" works with
this particular printer.



> Now two questions are left:
> 
> 1. How the heck do I print text files with this setup? Should I convert
> them to PostScript first, and how? UTF-8 Cyrillic support is crucial.

Yes, gs expects PS as its input. For programs that print
(except here: Firefox), PS is the default output anyway.
But if you have ASCII text, you need to turn it into PS.

The easiest way to do this is the port "a2ps" (ASCII to
PostScript). It has several options that you can tweak
if the default output is not sufficiently formatted,
like headers or margins.

Personally, I use "encript" for turning ASCII reports
into formatted pages. Here is an example:

	enscript -o ta_t4_${ACCT}.ps \
		--media=A4 \
		--margins=50:10:10:10 \
		--font=Courier11 \
		--header="Transactions for ${ACCT}"'||Page $% of $=' \
		ta_t4_${ACCT}.txt

Last entry is the input file, -o specifies the output
file. You can use - for both or use | to "pass data".
This kind of PS can then be easily printed.



> 2. How do I convince Mozilla Firefox that I now have a PostScript
> printer and it can print directly to it, not just to a PDF file? It does
> not seem to care for /etc/printcap.

Correct. Firefox doesn't care what you want. ;-)

The default "print to file" of Firefox now uses PDF, as
many modern printers accept PDF directly. But you can use
the tool "pdftops" installed by the port "xpdf".

Sidenote: You can even put this into an additional printer
filter in /etc/printcap, for example with the printer name
"pdf", and address that printer from Firefox's print dialog,
to do this preprocessing.



And the printer will keep working even if both Brother and
"Windows" have stopped offering a driver for it... ;-)


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200505185510.00b622e3.freebsd>