OpenPrinting / system-config-printer

Graphical user interface for CUPS administration
GNU General Public License v2.0
156 stars 87 forks source link

Linux cups how to change printer's page size #288

Closed darkworks closed 1 year ago

darkworks commented 1 year ago

Am wondering how can we change printer media size to specific another one from terminal. I checked lp and lpoptions documentation but not found any specific flag regarding media size set. I have created Media size by name myLabel_size so was wondering if can select it from cli so that i can then add it to my script.

i tried various commands but no success like some of them i tried are

lp -o media=myLabel_size
lp -o "PageSize/Media Size"=myLabel_size   
lp -o "PageSize"=myLabel_size
lp -o "Media Size"=myLabel_size
lpoptions -o "PageSize/Media Size"=myLabel_size   
lpoptions -o "PageSize"=myLabel_size
lpoptions -o "Media Size"=myLabel_size

lpoptions -o media=myLabel_size
lpoptions -o PageSize=29x35

enter image description here

Am on linux mint and system config printer v1.5.12 is installed

image

so the gods who made this gui app can you guys tell how to do it from terminal as i have to select custom profile for my script to sent pdf print command to printer.

thanks

zdohnal commented 1 year ago

Hi,

check the output of lpoptions -p <printer> -l , where is the printer name from lpstat -e, and use the option name and value from the output.

F.e.:

$ lpstat -e
hp-test

$ lpoptions -p hp-test -l
PageSize/Media Size: 100x150mm 184x260mm 195x270mm 4x6 5x8 *A4 A5 A6 B5 B6 DoublePostcardRotated Env10 EnvC5 EnvDL EnvMonarch Executive FanFoldGermanLegal ISOB5 Legal Letter Oficio Postcard roc16k Custom.WIDTHxHEIGHT
InputSlot/Media Source: *Auto Manual Tray1 Tray2
MediaType/Media Type: *Stationery HPMatte90gsm HPMatte105gsm HPMatte120gsm HPMatte160gsm HPCover HPGlossy130gsm PhotographicGlossy HPTrifoldGlossy160gsm HPGlossyPhoto StationeryLightweight ExtraLight Intermediate Midweight StationeryHeavyweight ExtraHeavy PhotographicHighGloss ExtraHeavyGloss CardGlossy Transparency Labels StationeryLetterhead Envelope EnvelopeHeavyweight StationeryPreprinted StationeryPrepunched StationeryColored StationeryBond Recycled Rough HeavyRough PhotographicFilm
ColorModel/Output Mode: Gray AdobeRGB DeviceRGB DeviceGray *RGB
Duplex/Duplex: *None DuplexNoTumble DuplexTumble
OutputBin/OutputBin: *FaceDown
cupsPrintQuality/cupsPrintQuality: Draft *Normal

In case your new size is not shown, there is probably an error in its definition - I'm not sure how and where you've create a new size, but if you updated the ppd file, you will probably have to restart cups or reinstall the print queue to recognize the size.

However, if your driver already supports custom definitions (classic PPD shows it as Custom.WIDTHxHEIGHT in lpoptions output), you can define such custom sizes by the options from this old comment.

darkworks commented 1 year ago

well the brothers printers allow to create and delete customs profiles like here you can see from the GUI i have selected my profile which exists

image

it was created using brpapertoollpr_ql710w utility sudo brpapertoollpr_ql710w -P QL-710W -n myLabel_size -w 29 -h 35

this is why i was saying how to select it from the terminal because the system-config-printer is able to do it via clicks so thought you guys might be executing commands on backed about which i was asking.

so after executing lpoptions -p QL-710W -l i got something like this

PageSize/Media Size: 17x54 17x87 23x23 29x42 29x90 38x90 39x48 52x29 60x86 62x29 62x100 12Dia 24Dia 58Dia 12X1 29X1 38X1 50X1 54X1 62X1 12X2 29X2 38X2 50X2 54X2 62X2 12X3 29X3 38X3 50X3 54X3 62X3 12X4 29X4 38X4 50X4 54X4 62X4 BrL0B1D03C873FF BrL081D023DEDDA *BrL081D03C34721 BrL0C1D023B0F36
BrMargin/Feed(invalid for Die-Cut tape): *3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
BrPriority/Quality: BrSpeed *BrQuality

it not contain my custom size myLabel_size . however you can see in above screenshot that system-config-printer app is displaying myLabel_size in list and when selected it works to i mean printer print according to it. so i not understand how on backend you guys doing it like fetching these pages sizes which includes my custom created and its also applied perfectly too. so some tips on switching these page sizes from terminals will be good as i have two page sizes myLabel_size and myLabel_size2 i send prints to my printer through script so i would like to switch between these two pagesizes from terminal. currently i have to switch between pages sizes from the GUI of system-config-printer app manually. thanks