From owner-freebsd-questions@freebsd.org Tue May 5 18:23:37 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1EA282C05E9 for ; Tue, 5 May 2020 18:23:37 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49Gp541QMQz4MSd for ; Tue, 5 May 2020 18:23:35 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([94.222.9.16]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPA (Nemesis) id 1N2VCb-1j95oo0EVr-013vkp; Tue, 05 May 2020 20:23:33 +0200 Date: Tue, 5 May 2020 20:23:31 +0200 From: Polytropon To: Victor Sudakov Cc: freebsd-questions@freebsd.org Subject: Re: Brother HL-L2340D printer and lpd? Message-Id: <20200505202331.53374f21.freebsd@edvax.de> In-Reply-To: <20200505180101.GA35751@admin.sibptus.ru> References: <20200503171259.GA48627@admin.sibptus.ru> <20200505161952.GA34844@admin.sibptus.ru> <20200505185510.00b622e3.freebsd@edvax.de> <20200505180101.GA35751@admin.sibptus.ru> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:rqpf0ro/sGQuMmX3M+XvJ1yGqhu3A+fFEJ9bHWlrzV7Jzg17epu 2uu63kOzouMqo/hYsTGv/aVD5YyM0G9UzQnT7oxdAX8Ia9na1i5mf1fc+llKHuTN9E25diu wt463wqfTK7/k+d87dRkDry9gtBXJ3ab0/R9j+QmgRUEpHYwGgh+dySvfvPxmuJILqUA9jg 6LTcJvkeLbCJhqRq7l4tA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:ylYCSsPSO4A=:W/M/p0Ri+lukWS4vh793kL IWB8Thzddn9YJA5ZL8wFQWsSDt7BWgXS0yY86wTmVqc0df4sckQasj7R46D2CITrt1P11d8lN 2InRFTQDpavhbw4Y3NhuypOgi4T0DWy4POxvXioIZPZoUY3ePTAsf3y2oPXzJMPZjb3uup/tx I5N6xAOCdW0rRklv5rzgefcRaZc5IwFljh5yd/VJ4OjTz6QB6Cwwf2pax63X7KxYlCrTeiAnw uGxZ9mAGZTTjW9YnUFiL65In0XuqOEFG/bkBUTrKXksDN9IwpxAtl9VmTzpmIoILhrAI0D60m kFXV7j4SoifZRSyPtvloGYi4/H2WQDwd2uGESDD6ElBahVN/aqDMZMp3xMA6U8yxcARpBcgHR EyjcOy3NQy9KlT2ZejG7vpk+KRPAWkeTiAWadCrbpo20RhPZm+8gihh0yotwrtFyIOD163li6 3pxhe+fA0AHYo7ytwDC0YbtPbQ7V5r9uCrsv6SltPdYj2pzdysFs23B45pRla3HlARXSyIpUG THRwg5VoCrT8lLO3BNhXszxgVpJISHLf2M34iiqiZfHQ7k/nXRSRqVgeB1WfghP/jkCUTvlXn LCFNndHwwQBem2vqj2K+jhnGDQmpiuaM+koev4yXdURkt6zckL8Cmsrx8IP410MPcrA938Ek0 IT+EHVvfhJnXtTb66q4dOf5rEAYvDiszuV9MaNujq0VSCCva9pPWBwh35Tb6ZuMw3gOEo/tt7 uQjj7S27Wwdb7WPOUqKblctYJkk9n3VL3SzcWAs3fpbI8oDq+P22jiLjasRoceI2/e/FNe5CT 05c0D1hqCDFM7LppsMreyebpeiC+8u128DOFCK8JVu2jjBfia84jhUEvWGFnZomoHXuM8v8 X-Rspamd-Queue-Id: 49Gp541QMQz4MSd X-Spamd-Bar: +++++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 217.72.192.73) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [5.80 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8560, ipnet:217.72.192.0/20, country:DE]; SUBJECT_ENDS_QUESTION(1.00)[]; SH_EMAIL_ZRD(0.00)[192.168.1.74]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; SH_EMAIL_DBL_DONT_QUERY_IPS(0.00)[192.168.1.74]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.98)[0.979,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(1.00)[1.000,0]; RCVD_IN_DNSWL_NONE(0.00)[73.192.72.217.list.dnswl.org : 127.0.5.0]; MID_CONTAINS_FROM(1.00)[]; R_SPF_NA(0.00)[]; RWL_MAILSPIKE_VERYGOOD(0.00)[73.192.72.217.rep.mailspike.net : 127.0.0.19]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(0.42)[ip: (-0.18), ipnet: 217.72.192.0/20(0.28), asn: 8560(2.04), country: DE(-0.02)] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 May 2020 18:23:37 -0000 On Wed, 6 May 2020 01:01:01 +0700, Victor Sudakov wrote: > Polytropon 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. :-) > > A PostScript translator (GhostScript or any other) can be expected to > "raster" the PS input incorrectly if this input contains encodings it does > not understand, or glyphs/fonts it is lacking. Yes, especially if the construction of the PS (or the PDF it is generated from) is incomplete. But if the input is already rastered - no problem. :-) > I've seen so many problems with Cyrillic in my life, believe me. I've > seen PDFs with some Cyrillic glyphs replaced by garbage, and much more > of such weird stuff than I wish to see. I think that's also a result of UTF-8 vs. CP-866 vs. KOI-8 single / multi-byte mapping... yes, the german language is still suffering from the same problem. > > Thanks for posting the _solution_ to your problem. Future > > readers will now know that gs's filter "hl1250" works with > > this particular printer. > > This is not a final solution. I'm currently hacking the Linux LPR > "driver" for this printer (hll2340dlpr-3.2.0-1.i386.deb), and maybe > (just maybe) I'll be able to figure out what Linux sends to it to enable > ascii LPR printing. > > In this package, there is a promising small linux binary which Linux > uses as an if=. I guess it has magic within. > > > > > > > > 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 > > a2ps from packages is broken: > > $ a2ps /etc/rc.conf > a2ps: unknown medium `libpaper' Install "libpaper" package and manually set a symlink in /usr/local/etc: papersize -> papersize.a4 for standard ISO A4 paper, or papersize -> papersize.letter for US letter. Also note that a2ps outputs to stdout, so you'll probably want redirection: % a2ps /etc/rc.conf > rc.conf.ps Note that you'll probably have to "man a2ps" to deviate from the standard options, because those generate "2 pages on 1 with header" layout. > > Personally, I use "encript" for turning ASCII reports > > enscript is good, but it has huge problems with Cyrillic, and is totally > lacking multibyte support (UTF-8). Correct. That's why I had to use it with ISO-8859-1 standard western europe character set (single byte per symbol) in order to get Umlauts displayed correctly. Maybe another processing step ("recode utf-8..koi8 ") can be used in the printer filter. > > > 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". > > No, it's not necessary, GhostScript eats PDFs just fine. Cool, I didn't know that. > > and address that printer from Firefox's print dialog, > > Oh! I wish I knew how to add something to Firefox's print dialog! > Do you? If you define several printers in /etc/printcap (and not forget to run cap_mkdb), a system running lpr should have the available printers listed in Firefox's print dialog. Unless, of course, Firefox is hard-wired with CUPS, and no CUPS - no printer selection. Another idea might be to use the variable $PRINTER to name the printer before starting Firefox. This variable will also be used by the lp* tools if no -P is specified. I often use this as my default printer never is named "lp". :-) % lpq Laserjet is ready no entries Currently I don't have access to a system that has both Firefox and lpr installed so I cannot verify this suggestion. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...