pdewacht / brlaser

Brother laser printer driver
GNU General Public License v2.0
592 stars 112 forks source link

Support custom page sizes #91

Open wolfgang42 opened 4 years ago

wolfgang42 commented 4 years ago

I have a Brother HL-2320D, which can print on custom page sizes when used via a Mac. (In particular, I’m trying to print on 4x6 cards, but I’m sure other sizes will be useful in the future.) However, it seems that brlaser hard-codes a list of paper sizes that it supports.

It looks like this is because brlaser uses the SET PAPER command to tell the printer the media size. Some rummaging around the Internet turned up SET PAPERLENGTH/SET PAPERWIDTH (in tenths of a point, I think); but I’ve been unable to find any documentation from Brother that their printers all support this command, and I’ve not tried it on my own printer yet.

jordanbakke commented 3 years ago

Reference Manual

It lists all supported PJL variables, and neither PAPERWIDTH nor PAPERLENGTH are in the document. For some models, PAPER can be set to USERDEF or USERDEFINED, but I haven't figured out how to specify actual numbers.

Email thread where someone tries to do the same thing

Looks like maybe the printer interprets a proprietary format for custom page sizes.

Edit: I tried it myself (on an HL-L2320) and I used Wireshark to verify the driver was setting PAPERWIDTH and PAPERLENGTH and not PAPER, and it just printed the image where the upper-left corner of a letter sized page would be.

wolfgang42 commented 3 years ago

I printed this 4×6″ PDF on my Mac using the standard drivers, and captured this packet trace which has the following in the PJL header:

@PJL SET ORIENTATION = PORTRAIT
@PJL SET PAPER = COM10

COM10 is the size of a number 10 envelope, which is 4⅛×9½″. I haven’t tried decoding the image data, but I wonder if the driver just picks the next largest standard size and then offsets the image to center it horizontally?