{"id":232,"date":"2004-02-07T21:35:00","date_gmt":"2004-02-07T21:35:00","guid":{"rendered":"http:\/\/www.bolis.com\/testwp\/story\/printing-greeting-cards-in-linux\/"},"modified":"2016-11-27T08:43:49","modified_gmt":"2016-11-27T08:43:49","slug":"printing-greeting-cards-in-linux","status":"publish","type":"post","link":"http:\/\/www.bolis.com\/amillar\/printing-greeting-cards-in-linux\/","title":{"rendered":"Printing Greeting Cards in Linux"},"content":{"rendered":"<br \/>\n<table>\n<tr>\n<td>Linux in a Nutshell<br \/><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/images.amazon.com\/images\/P\/0596004826.01.TZZZZZZZ.jpg\" border=\"0\" alt=\"cover\" hspace=\"3\" vspace=\"3\" width=\"70\" height=\"90\" \/><br \/><a href=\"http:\/\/www.amazon.com\/exec\/obidos\/ASIN\/0596004826\/boliscom-20\">Amazon<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.assoc-amazon.com\/e\/ir?t=boliscom-20&amp;l=ur2&amp;o=1\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" style=\"border:none !important; margin:0px !important;\" \/><\/a>\u00a0|\u00a0<a href=\"http:\/\/www.powells.com\/cgi-bin\/partner?partner_id=26361&amp;cgi=product&amp;isbn=0596004826\">Powells<\/a><br \/><a href=\"http:\/\/www.indiebound.org\/book\/0596004826?aff=amillar\">IndieBound<\/a><\/td>\n<\/tr>\n<\/table>\n<p> Many people are familiar with the &#8220;print your own greeting card&#8221; idea. You print four small page images on a single sheet of paper and fold it in half twice.  You get a little greeting card with a custom cover and interior, all from one single-sided piece of paper.<\/p>\n<p> I wanted to do this from a Linux application, without needing Windows or MacOS.  Preferably, I could use any application to produce 4 pages, and have some magic transform it into the single page with all parts reduced and oriented properly for folding.<\/p>\n<p> After a little <a href=\"http:\/\/www.google.com\">googling<\/a>, I was able to find  <a href=\"http:\/\/slug.archives.nks.net\/List\/slug.archive.0204\/0122.html\">this list archive message<\/a> by Ronan Heffernan describing exactly what I wanted.  His &#8220;make_card&#8221; script takes a postscript file and does the appropriate transformation: <\/p>\n<blockquote><p>#!\/bin\/shcat $1 | pstops -pletter -b &#8220;4:3U@.5(1w,1h)+0U@.5(.5w,1h)+1@.5(0,0)+2@.5(.5w,0)&#8221; &gt; $2<\/p><\/blockquote>\n<p>This works well, but I wanted something that my family could use from<br \/>Linux apps without the command line.  <\/p>\n<p>My favorite print spool tool in Linux is <a href=\"http:\/\/printing.kde.org\/overview\/kprinter.php\">KPrinter<\/a> from <a href=\"http:\/\/www.kde.org\">KDE<\/a> 3.0.  It can be used with any X Window application, not just KDE apps.  It is <i>perfect<\/i> for the generic X apps like<br \/><a href=\"http:\/\/www.mozilla.org\">Mozilla<\/a> and <a href=\"http:\/\/www.adobe.com\/products\/acrobat\/readermain.html\">Acrobat Reader<\/a>.  Instead of sending print output to the command lpr, send it to the command kprinter (or kprinter &#8211;stdin if it pipes it).<\/p>\n<p>The method I found is to create a &#8220;prefilter&#8221; for KPrinter.  This<br \/>allows you to select greeting card formatting for any print job to<br \/>any printer.<\/p>\n<p>Create the following files:<\/p>\n<blockquote>\n<h3>\/usr\/share\/apps\/kdeprint\/filters\/Greeting-card-4-up.desktop<\/h3>\n<p>[KDE Print Filter Entry]Comment=Greeting card- 4 pages on double-folded US letterMimeTypeIn=application\/postscriptMimeTypeOut=application\/postscriptRequire=exec:\/ps2ps<\/p>\n<h3>\/usr\/share\/apps\/kdeprint\/filters\/Greeting-card-4-up.xml<\/h3>\n<p>&lt;!DOCTYPE kprintfilter&gt;&lt;kprintfilter name=&#8221;Greeting-card-4-up&#8221; &gt;&lt;filtercommand data=&#8221;pstops -pletter -b   &#8216;4:3U@.5(1w,1h)+0U@.5(.5w,1h)+1@.5(0,0)+2@.5(.5w,0)&#8217;   %filterinput %filteroutput&#8221; \/&gt; &lt;filterinput&gt;&lt;filterarg format=&#8221;%in&#8221; name=&#8221;file&#8221; \/&gt;  &lt;filterarg format=&#8221;&#8221; name=&#8221;pipe&#8221; \/&gt; &lt;\/filterinput&gt; &lt;filteroutput&gt;&lt;filterarg format=&#8221;&gt; %out&#8221; name=&#8221;file&#8221; \/&gt;  &lt;filterarg format=&#8221;&#8221; name=&#8221;pipe&#8221; \/&gt;&lt;\/filteroutput&gt;&lt;\/kprintfilter&gt;<\/p><\/blockquote>\n<p>I found that the KDE prefilters were not terribly well documented, but I<br \/>was able to muddle through it.  To create one, run KPrinter and select<br \/>&#8220;System Options&#8221;.  In the print configuration dialog box, select &#8220;Commands&#8221;.<br \/>This will allow you to create a new filter.  You simply need to compare the<br \/>entries to other existing print filters.<\/p>\n<p>When your new filter is created, it will be in your personal directory, such as<\/p>\n<p>$HOME\/.kde\/share\/apps\/kdeprint\/filters\/<\/p>\n<p>Move it to your system-wide print filter directory, which might be<\/p>\n<p>\/usr\/share\/apps\/kdeprint\/filters\/<\/p>\n<p>or something similar.<\/p>\n<p>I could not get the paper size to work automatically using the poorly-documented<br \/>paper size substitution variable, so I had to hard-code the US Letter paper<br \/>size.  If anyone knows how to fix this, let me know.<\/p>\n<ul class=\"links inline\">\n<li class=\"taxonomy_term_40 first\"><a href=\"\/amillar\/category\/primary-topic\/linux\" rel=\"tag\" title=\"\">Linux<\/a><\/li>\n<li class=\"taxonomy_term_17\"><a href=\"\/amillar\/topic\/computers\" rel=\"tag\" title=\"Computers are a significant hobby of mine, as well as being the primary focus of my career.  I enjoy many aspects of it, especially making older, marginalized, or obsolete technology do things people would not expect was still doable.  In some ways I am sort of a &quot;bottom feeder in the cyberspace food chain&quot;.\">Computers<\/a><\/li>\n<li class=\"taxonomy_term_34\"><a href=\"\/amillar\/topic\/linux\" rel=\"tag\" title=\"\">Linux<\/a><\/li>\n<li class=\"taxonomy_term_33 last\"><a href=\"\/amillar\/topic\/software\" rel=\"tag\" title=\" \">Software<\/a><\/li>\n<\/ul>\n<p>        Submitted by amillar on Sat, 2004-02-07 13:35                                <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux in a NutshellAmazon\u00a0|\u00a0PowellsIndieBound Many people are familiar with the &#8220;print your own greeting card&#8221; idea. You print four small page images on a single sheet of paper and fold it in half twice. You get a little greeting card with a custom cover and interior, all from one single-sided piece of paper. I wanted &hellip; <a href=\"http:\/\/www.bolis.com\/amillar\/printing-greeting-cards-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Printing Greeting Cards in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[13],"class_list":["post-232","post","type-post","status-publish","format-standard","hentry","category-project","tag-linux"],"acf":[],"_links":{"self":[{"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/posts\/232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/comments?post=232"}],"version-history":[{"count":1,"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/posts\/232\/revisions"}],"predecessor-version":[{"id":306,"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/posts\/232\/revisions\/306"}],"wp:attachment":[{"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/media?parent=232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/categories?post=232"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bolis.com\/amillar\/wp-json\/wp\/v2\/tags?post=232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}