How to print from command line on Linux overriding default settings like 'fit to page'
By default, documents on Linux are printed with the 'fit to page' setting enabled, i.e. text is scaled to fit the paper size.
To avoid that text is shrinked to adapt to the page, it's possible to specify additional options in the command line used for printing. This can be done also when connected by NoMachine to the remote Linux host:
1) Connect by NoMachine to the remote computer.
2) Connect a local printer and make it available from the user's computer to the NoMachine session.
3) Inside the NoMachine session open a terminal and execute the following command to list all the printers available on server side:
| lpstat -a -d |
4) Print the file from command line on a specific printer. The name of printers forwarded via NoMachine has 'NoMachine' as postfix. For example:
| lp -d HP_LaserJet_1018_NoMachine ~/Desktop/index.jpeg |
This command prints the file with the default settings, included the 'fit to page' one.
To print without scaling content to the page size it's necessary to specify an additional parameter. When 'fit to page' is disabled, it's possible to specify also the percentage of the scale value:
-o fitplot=False turn off printing in ‘fit-to-page’ mode
When 'fit to page' is disabled, it's possible to specify also how a printed image will be scaled:
-o natural-scaling=percent scale the image in relation to the natural image size
-o scaling =percent scale the image in relation to the page
For example:
| lp -d HP_LaserJet_1018_NoMachine -o fitplot=False -o natural-scaling=400 ~/Desktop/index.jpeg |
For more details about the available options and their usage, we recommend to refer to the official CUPS documentation at https://www.cups.org/documentation.html.
Note: in a similar way it's possible to print from command line also on Mac.
|
|||
|
|||
|
To disable 'fit to page' by default when printing from command line, it's possible to create a wrapper script which executes the lp command with the appropriate options. a) Rename /usr/bin/lp to /usr/bin/lp.ori
if [ -e "/usr/bin/lp" ]; $LP_COMMAND "$@" -o fitplot=False
d) Ensure that the new wrapper script, lp, has the same ownership and permissions of the original one. |
|||
