Thursday, September 6, 2007

Printing Secrets Revealed: How to set Custom Page Sizes with CUPS Printjobs

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 \
-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)

These assume a few things:
  • 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")
The "fit onto the medium" will happen automatically. CUPS will scale the page image up or down to the size that makes you PDF fit onto the sheet. It will also automatically rotate a page, if that makes it fit better into the available space.

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 \
/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 ;

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").

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 \
-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

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...

42 comments:

Unknown said...

Wow. This is great info and you're just getting started. I can't wait to learn more!

Anonymous said...

Superb info!

Just what I was looking for, spoon fed to me and my little /dev/brain :-)

Thanks a lot.

Anonymous said...

Superest Info!
I use it ungently.thank you very much.

Great net said...

Dear Writer, I bookmark your Blog For Reading I really love your Blog Post Please Keep update Reguraly.


________________________
I m From Online printing company

CCTV Moran El Salvador said...

Hi, txs 4 explanetion

I have a ubuntu 9.10 distro
Bu i've tried to add PageSize to mi printer epson lx300
but in comand line, i culdn't
how ca i do it better?
so, but what is different way if i have this printer sharing on pcwin?

Boxes Printing said...

Really nice information thanks for share it.

3d ultrasounds said...

Interesting post. I have been wondering about this issue,so thanks for posting.

reversal of tubal ligation said...

Brilliant post and useful information…I think this is what I read somewhere…but I don’t know with your experience

printing london said...

Great information sharing with us. Thanks for it.

thermal bags said...

Thank you very much for that extraordinarily first class editorial! Very creative, one of the nicer sites I have seen today. Keep up the great work.

Organic Supplements said...

I believe that natural and organic sources of vitamins and minerals are the best in comparison of any other packaged and plastic products. Always try to grow the stuff you need at your home. It is not only going to be cheaper but it will be a lot more beneficial for your health and your loved ones

Free Classified Ads said...

For this motive to provide every product to the customer, and to accomplish the all needs of the people we introduce an authentic and valuable E-marketing place where mushroom of beautiful and well equipped houses and accommodations are provided by the so worthy and trusty E-marketing place which is geboon.com .

3d ultrasounds said...

Well described in above article.
It’s very informative and impressive.
Thanks for your update.

website design perth said...

Many people will take advantage of this credit. This will also give us a clearer picture of the housing market, as there will be no special incentive to buy after the credit is no longer offered.

Lingerie said...

Thanks for sharing this great article! I feel strongly about it and love learning more on this topic. It is extremely helpful for me. I hope you post again soon

Copyright UK said...

This post is a winner! Love the tips and everything you suggest..

emergency locksmith said...

Thanks for the information. I’m really glad that you share your ideas about this. I must relay this ideas to my friends.

organic supplements said...

Thanks for putting this together! This is obviously one great post.

Unknown said...

Your blog post is very unique and well research, Thanks for your research on academic knowledge.
Advertising agencies in Karachi | Advertising agencies in Pakistan

Custom Tumblers said...

I honestly don't even know how much I spent for everything anymore. If I had to guess, it was probably about $4 a cup. I bought big sheets of vinyl at a local sign shop and only needed one!

Unknown said...

hello.
i use :: arch linux
epson tm-t20ii
using wine for a simple 32bit exe dotnet 4.0 ie8
need to custom fit a page size
created and installed package myself not in aur.
i can print from the exe software but even after i set custom page size via web gui it still reverts back to a standard format.
would the best solution be editing the ppd file to contain ONLY the page size i want?

Steph said...

custom printing works.

savagej said...

there is an error on the system called epson communication error, I have no idea on how the error was implemented, it is not letting me print anything and is really unresponsive, any solution would be appreciated.

Randalcato said...

After looking at a number of the blog posts on your blog, I seriously appreciate your way of writing a blog. I book-marked it to my bookmark website list and will be checking back soon. Take a look at my website too and let me know how you feel https://club-powerball.com/.

Happy Vanlentine Day said...

These websites are really needed, you can learn a lot. 안전사이트 추천

Happy Vanlentine Day said...

We are a group of creative professionals, having extensive work experience to help you in complete marketing solutions from print to web. https://carbonrepro.com


MTTMT said...

Hello, I really enjoyed reading your post. It's very helpful for me. Actually, I'm doing something similar to you. It's not exactly the same, but we have a lot in common. As for what I do, I have uploaded a lot of posts on my website. If you're interested, please visit and read it. Thank you. Have a nice day. 토토사이트

esesanggwachun said...

Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! However, how could we communicate? 토토

토토사이트 said...

What an interesting story! I'm glad I finally found what I was looking for Excellent reading, I read a lot of posts but I am really impressed with your post. Thanks sir, I will look into this article. To know about me, try talking to 먹튀검증.

메이저사이트 said...

먹튀검증We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Great work

메이저사이트 said...

Truly quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. Much obliged for sharing.토토먹튀

먹튀검증 said...

This article is very interesting information. It has helped me a lot. Thank you very much for providing this quality information in an easy-to-understand manner. Our site also provides high-quality information, so it will be helpful for your site. 토토사이트먹튀

토토커뮤니티 said...

Please take good care of me from now on.Thank you.Cool. I'll be back every day. 꽁머니

토토커뮤니티 said...

I can grow up with. Please continue to do well and always do well.The Design looks very good..안전사이트

leea112 said...

Perfect piece of work you have done, this internet site is really cool with good information.먹튀검증

aaaaaaa said...


온라인카지노 우리카지노 계열 중 원탑을 달리고있는 더킹카지노는 아직 만족하지 않고 온라인카지노 길에 큰 획을 그으며 점직적으로 앞을향해 나아가고 있습니다. 그 끝은 어디일까요? 안전한 우리카지노사이트 를 찾으시나요? 앞서걷는 길이 말합니다. 독보적 1위 더킹카지노입니다.더존카지노

bamgosoo said...



Hi, its nice post concerning media print, we all understand media is a enormous source of information.

Feel free to surf to my web blog ... 오피
(jk)



Unknown said...

Online Baccarat / Woori Casino / Merit Casino / First Casino
Topsum, an online baccarat verification company, selects and recommends only verified online baccarat sites. As the longest-running verification company in the industry, we only recommend companies with strong security and safety in our casino that has not changed for 20 years based on our know-how.

LIVE카지노

온라인바카라

우리카지노

바카라사이트

카지노사이트

Unknown said...

This site seems to inspire me a lot. Thank you so much for organizing and providing this quality information in an easy to understand way. I think that a healthy era of big data can be maintained only when such high-quality information is continuously produced. And I, too, are working hard to organize and provide such high-quality information. It would be nice to come in once and get information.

Also visit my site:안전토토사이트

Digisol Hub said...

Digisol Hub is an advanced tech company, we can help you find solutions with your Website Development problems, Marketing of Social Media, development of applications (Apps), Graphic designing, Google Ads, and development of Software. Our aim is to help people solve their problems regarding digital marketing by using the right strategy and make them feel valued so they progress with their online business.
Digisol Hub

Sufia Seikh said...

This is very good blog post, I like the way you pointed all stuff, must follow below useful links

POS Systems
point of sale systems
pos solution dubai
restaurant pos
retail software dubai
saloon software
inventory management software
warehouse management software
barcode printer dubai
barcode solutions dubai

lalitaheaglin said...

How does the casino work? - Dr.MCD
Casino 영천 출장마사지 players can deposit 정읍 출장안마 in 포항 출장마사지 and withdraw in various ways in a number of different forms such as cash, debit cards, or 경상북도 출장샵 credit cards. However, 원주 출장샵 players