Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brother HL-L2390 prints as if set to A4 when set to letter #53027

Closed
msuperdock opened this issue Dec 29, 2018 · 12 comments
Closed

Brother HL-L2390 prints as if set to A4 when set to letter #53027

msuperdock opened this issue Dec 29, 2018 · 12 comments

Comments

@msuperdock
Copy link

Background

With help from IRC, I was able to set up my Brother HL-L2350DW printer on NixOS by imitating the existing derivation for hll2390dw-cups. Then @samueldr, who maintains that derivation, pointed out that his printer prints letter files as if set to A4, and I noticed my printer was doing the same. He shared his fix, which also worked for me for the HL-L2350DW. The fix is a bit of a hack, which in my understanding is why he hasn't submitted it to nixpkgs. I'm filing this issue to document it and to share a working derivation for the HL-L2350DW printer.

Issue description

The current Brother HL-L2390DW driver (hll2390dw-cups) prints as if set to A4 when set to letter, causing text to run off the right and bottom sides of the paper.

Steps to reproduce

  • Put hll2390dw-cups in services.printing.drivers and rebuild nixos.
  • Open the cups web interface and add the printer. (The driver appears immediately.)
  • Choose a pdf file to print, check that it is letter size with pdfinfo [filename].
  • Print, e.g. with lpr -p [printername] [filename].

The text will run off the right and bottom of the page.

Known fix

See @samueldr's fix here.

Notes on Brother HL-L2350DW

Below is a working derivation for the Brother HL-L2350DW. It is a copy of the derivation for hll2390dw-cups, with the download url and printer name changed. I am also including @samueldr's fix.

For other printers in the HL-L23x0DW line, I would suggest downloading the .deb package from the Brother support site. If its version is 4.0.0-1, it is likely essentially the same as the package for the HL-L2390DW and HL-L2350DW, and an equivalent derivation should work; just modify the fetchurl section (use nix-prefetch-url to get the hash) and the printer name. You can put the following in its own .nix file (say, printer.nix) and call it from configuration.nix with something like services.printing.drivers = [ (pkgs.callPackage ./printer.nix {}) ];.

Derivation for HL-L2350DW:

{ stdenv, fetchurl, makeWrapper
, cups
, dpkg
, a2ps, ghostscript, gnugrep, gnused, coreutils, file, perl, which
}:

stdenv.mkDerivation rec {
  name = "hll2350dw-cups-${version}";
  version = "4.0.0-1";

  src = fetchurl {
    url = "https://download.brother.com/welcome/dlf103566/hll2350dwpdrv-${version}.i386.deb";
    sha256 = "0b7hhln105agc3rwpi7cjlx5nf4d2yk9iksahdv3725nnd06lg46";
  };

  nativeBuildInputs = [ makeWrapper ];
  buildInputs = [ cups ghostscript dpkg a2ps ];

  unpackPhase = ":";

  installPhase = ''
    dpkg-deb -x $src $out

    substituteInPlace $out/opt/brother/Printers/HLL2350DW/lpd/lpdfilter \
      --replace /opt "$out/opt" \
      --replace /usr/bin/perl ${perl}/bin/perl \
      --replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$out\"; #" \
      --replace "PRINTER =~" "PRINTER = \"HLL2350DW\"; #"

    # FIXME : Allow i686 and armv7l variations to be setup instead.
    _PLAT=x86_64
    patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
      $out/opt/brother/Printers/HLL2350DW/lpd/$_PLAT/brprintconflsr3
    patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
      $out/opt/brother/Printers/HLL2350DW/lpd/$_PLAT/rawtobr3
    ln -s $out/opt/brother/Printers/HLL2350DW/lpd/$_PLAT/brprintconflsr3 $out/opt/brother/Printers/HLL2350DW/lpd/brprintconflsr3
    ln -s $out/opt/brother/Printers/HLL2350DW/lpd/$_PLAT/rawtobr3 $out/opt/brother/Printers/HLL2350DW/lpd/rawtobr3

    for f in \
      $out/opt/brother/Printers/HLL2350DW/cupswrapper/lpdwrapper \
      $out/opt/brother/Printers/HLL2350DW/cupswrapper/paperconfigml2 \
    ; do
      #substituteInPlace $f \
      wrapProgram $f \
        --prefix PATH : ${stdenv.lib.makeBinPath [
          coreutils ghostscript gnugrep gnused
        ]}
    done

    # Hack suggested by samueldr.
    sed -i"" "s;A4;Letter;g" $out/opt/brother/Printers/HLL2350DW/inf/brHLL2350DWrc

    mkdir -p $out/lib/cups/filter/
    ln -s $out/opt/brother/Printers/HLL2350DW/lpd/lpdfilter $out/lib/cups/filter/brother_lpdwrapper_HLL2350DW

    mkdir -p $out/share/cups/model
    ln -s $out/opt/brother/Printers/HLL2350DW/cupswrapper/brother-HLL2350DW-cups-en.ppd $out/share/cups/model/

    wrapProgram $out/opt/brother/Printers/HLL2350DW/lpd/lpdfilter \
      --prefix PATH ":" ${ stdenv.lib.makeBinPath [ ghostscript a2ps file gnused gnugrep coreutils which ] }
    '';

  meta = with stdenv.lib; {
    homepage = "https://www.brother.com/";
    description = "Brother HL-L2350DW combined print driver";
    license = licenses.unfree;
    platforms = [
      "x86_64-linux"
    ];
    downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=us&lang=en&prod=hll2350dw_us_eu_as&os=128";
  };
}

Next steps

These are just ideas, to see if it makes sense to include @samueldr's fix in the hll2390dw-cups derivation, and to see if it makes sense to add a hll2350dw-cups derivation.

  • Check whether one can still print A4 with @samueldr's fix.
  • Check whether this A4/letter issue is also an issue in distributions that can install the official Brother packages directly, like Debian. (Maybe there is just a CUPS configuration step we're both missing.)
@eadwu
Copy link
Member

eadwu commented Dec 29, 2018

According to the ppd from what I can see, it's set to print using A4 by default. Try using lpd -o media=letter -p [printer] [filename] to see if it makes any difference.

       -o media=size
            Sets the page size to size. Most printers support at least the size names "a4", "letter", and "legal".

Besides that, tried adjusting the derivation to fix BR_PRT_PATH substitution in case that makes any difference, https://pastebin.com/raw/7WufVyR4.

@msuperdock
Copy link
Author

@eadwu:

I tried using lpd -o media=letter as you suggested, using my original file with the sed line removed, and the printer printed as if set to A4, just as it had originally.

I also tried the BR_PRT_PATH adjustment you suggested (by manually removing the ~ from my derivation above), but with that change, my printer did not respond to sending jobs via lpr at all--the CUPS administration page continued to show "Idle" despite sending a job several times.

I think the real issue here is that any options provided are ignored. At least, media=letter seems to be ignored, and setting two-sided printing seems to be ignored also (by using -o sides=two-sided-long-edge). This applies both to options provided to lpr at the command line and to options set on the CUPS default settings page. (Note that the CUPS default settings are listed in the same format as lpr options.) So, I now think all of the settings I'm providing to CUPS or lpr are being ignored.

So for now, I can get correct letter-size printing using the sed fix mentioned above. But I am unable to print two-sided, and I think a more general fix is needed.

@waxlamp
Copy link

waxlamp commented Jan 27, 2019

Thank you for figuring out this fix, @eadwu. It worked for my HL-L2395DW, but I'd also love to see a more general fix.

@msuperdock
Copy link
Author

@waxlamp: Are you saying using lpd -o media=letter fixed the issue where the printer always prints as if the paper is A4? Even without the sed "hack" in my original post? (Wondering if your experience might have any insight into why my system doesn't seem to respond to the media=letter option.)

@waxlamp
Copy link

waxlamp commented Jan 28, 2019

Sorry, I wasn't very clear about this: using lpd -o did NOT work for me, nor did changing default options for paper size via the CUPS interface. What did work was the sed hack. I know next to nothing about printer drivers but the sed hack makes me think that the A4 size is for whatever reason hard-coded into the script and therefore ignores runtime options.

@stale
Copy link

stale bot commented Jun 3, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 3, 2020
@waxlamp
Copy link

waxlamp commented Jun 9, 2020

still important to me

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 9, 2020
@stale
Copy link

stale bot commented Dec 6, 2020

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 6, 2020
@waxlamp
Copy link

waxlamp commented Dec 8, 2020

Still important to me.

@msuperdock and/or @samueldr, are there action items on this issue or should this be closed?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 8, 2020
@msuperdock
Copy link
Author

msuperdock commented Dec 9, 2020

As far as I know, my post above on Jan 16, 2019, is still the current state of things: there's a hacky fix to print to letter, and with or without the fix, certain (all?) command-line options passed to lpr are ignored. If we merge the fix, then the derivation won't allow printing to A4, so I don't think it makes sense to merge as is.

I think a reasonable solution would be to provide an option whose possible values are "A4" and "letter," with "A4" as the default, such that the fix is only applied if the given value is "letter."

Personally, I find this printer unreliable on Linux, even with this fix. I have no issues printing to it over WIFI from a laptop running OS X, but when I try to print over a wired connection from Linux, it just rejects the job about half the time with a generic error message. For this reason I'm not motivated to work on a solution here--my reluctant recommendation to Linux users with this printer is to print from a non-Linux machine. (If others have a better experience I'd like to hear!)

I am not opposed to closing this if no one else is interested in working on it.

@samueldr
Copy link
Member

I think, given @msuperdock's message, we can close this for the time being. There is nothing actionable here.

The information is still right here, in the issues tracker.

@picnoir
Copy link
Member

picnoir commented Feb 1, 2021

Thanks a lot for the derivation. You posting it here saved me quite some time. kudos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants