So you have one of those sophisticated office printer models with adjustable guides that allow you to use any weird media size (with some sensible min/max value for width and height)? And you don't know how to tell CUPS to use that size when printing? (Ah... you don't have such a printer, and you are about to skip this article? Wait. The content may still be useful to you. See the last paragraph.)
Easy. Try one of these commands then:
lp -d printername -o PageSize=Custom.4x6in \These assume a few things:
-o fitplot /path/to/PDF ; # inches
lp -d printername -o PageSize=Custom.4x8cm \
-o fitplot /path/to/PDF ; # cm
lp -d printername -o PageSize=Custom.440x310 \
-o fitplot /path/to/PDF ; # points (1/72 of an inch)
- you indeed have a printer named "printername" (how weird is this?!)
- you want to print a PDF file
- you want to make the printout fit onto the medium ("fitplot")
This works also if you print other file types. And it even allows you to use fractions of an inch or cm units:
lp -d printername -o PageSize=Custom.5.5x6.9in \Supported image formats for CUPS printing are all of the commonly know, plus some more obscure ones: JPEG, TIFF (but not multipage TIFF!), PNG, GIF, PNM, PPM, SUN Raster, .... When the CUPS scheduler receives a printfile, it applies its "auto-typing" mechanism against it to find out its file format ("MIME type").
/path/to/ASCII.txt ;
lp -d printername -o PageSize=Custom.5x8.2cm \
-o fitplot /path/to/Photo.jpg ;
lp -d printername -o PageSize=Custom.440x310 \
-o fitplot /path/to/Scanned.tif ;
The received job format is then converted by an appropriate filter into a different one to make it better suited for further processing. (Overall, there may not only be one filter, but a whole chain of different ones which form a pipeline until the job is in a format that can be consumed by the target printer.)
With image and graphic formats, the first filter in the chain typically is "imagetops" or "imagetoraster". Both these filters understand the "fitplot" parameter that you gave on the above commandline, and act accordingly while converting their input into PS (PostScript) or CUPS Raster format.
You did notice that the "fitplot" parameter was skipped in the printing of the text, yes? Well, it does not make much sense here. Instead, to customize the size of your printed text you can specify "cpi" (characters per inch) and "lpi", as well as top, bottom, left and/or right margins:
lp -d printername \So you think this "custom page size" tip isn't of much use for you? Hold on. You can use it to "print to file" and generate PostScript pages that do have appropriate BoundingBoxes for leaflets /brochures you are going to hand to a commercial printshop for transfer onto paper. Or you can further process said PostScript into a polished PDF presentation that fits exactly on the wide screen of your shiny new notebook. (You don't know how to "print to file"? You don't know how to convert a PostScript to PDF? I'll deal with questions like these in one of the next blog entries. So come back, if you are interested.) Tell me your own use case for the CUPS custom page size print option...
-o PageSize=Custom.10x12cm /path/to/ASCII.txt \
-o page-top=33 \
-o page-bottom=44 \
-o page-left=60 \
-o page-right=80 \
-o lpi=5.53 \
-o cpi=11.3 \
/var/log/cups/page_log
3 comments:
Wow. This is great info and you're just getting started. I can't wait to learn more!
Superb info!
Just what I was looking for, spoon fed to me and my little /dev/brain :-)
Thanks a lot.
Superest Info!
I use it ungently.thank you very much.
Post a Comment