- publishing free software manuals

Articles > Printing booklets with PSUTILS - support for creep (shingling)

Brian Gough (Network Theory Ltd)

When booklets are printed the thickness of the paper causes the innermost pages to stick out (compared with the outer pages). This is referred to as "creep", or "shingling", in the printing trade.

The edge of the booklet is normally trimmed, to create a flat edge, reducing the apparent outer margin on the innermost pages. To create a uniform outer margin the pages in the booklet should be shifted to compensate for this. The shift is linear in the number of pages.

The standard distribution of psutils only supports constant offsets, not linear shifts, so cannot be used to compensate for creep.

The patch below adds support for page-dependent shifts to the pstops command in psustils (version 17). The modifier "#" is used to indicate a page-dependent offset in the pstops command-line specification.

---------------------
PatchSet 3 
Date: 2004/04/23 15:39:20
Author: bjg
Branch: HEAD
Tag: (none) 
Log:
added support for creep (page-dependent offsets)

Members: 
	psspec.c:1.1->1.2 
	psspec.h:1.1->1.2 
	pstops.c:1.1->1.2 

Index: psutils/psspec.c
diff -u psutils/psspec.c:1.1 psutils/psspec.c:1.2
--- psutils/psspec.c:1.1	Fri Apr 23 15:37:12 2004
+++ psutils/psspec.c	Fri Apr 23 15:39:20 2004
@@ -201,7 +201,13 @@
 	    char buffer[BUFSIZ];
 	    writestring("PStoPSmatrix setmatrix\n");
 	    if (ps->flags & OFFSET) {
-	       sprintf(buffer, "%f %f translate\n", ps->xoff, ps->yoff);
+              if (ps->flags & CREEP) {
+                sprintf(buffer, "%f %f translate\n", 
+                        (ps->xoff*thispg)/modulo, 
+                        (ps->yoff*thispg)/modulo);
+              } else {
+                sprintf(buffer, "%f %f translate\n", ps->xoff, ps->yoff);
+              }
 	       writestring(buffer);
 	    }
 	    if (ps->flags & ROTATE) {
Index: psutils/psspec.h
diff -u psutils/psspec.h:1.1 psutils/psspec.h:1.2
--- psutils/psspec.h:1.1	Fri Apr 23 15:37:12 2004
+++ psutils/psspec.h	Fri Apr 23 15:39:20 2004
@@ -10,6 +10,7 @@
 #define ROTATE   (0x02)
 #define SCALE    (0x04)
 #define OFFSET   (0x08)
+#define CREEP    (0x10)
 #define GSAVE    (ROTATE|SCALE|OFFSET)

 typedef struct pagespec {
Index: psutils/pstops.c
diff -u psutils/pstops.c:1.1 psutils/pstops.c:1.2
--- psutils/pstops.c:1.1	Fri Apr 23 15:37:12 2004
+++ psutils/pstops.c	Fri Apr 23 15:39:20 2004
@@ -85,6 +85,10 @@
 	    tail->xoff += parsedimen(&str, argerror);
 	    if (*str++ != ',') argerror();
 	    tail->yoff += parsedimen(&str, argerror);
+            if (str[0] == '#') {
+              tail->flags |= CREEP;
+              str++;
+            };
 	    if (*str++ != ')') argerror();
 	    tail->flags |= OFFSET;
 	    break;

For example, the following command creates an A5 booklet, printed on A4 paper, with a 'creep' correction margin offset of 0.018cm per sheet of paper.

psbook file.ps 
 | pstops '4:0(0.018cm,0cm#),1(-0.018cm,0cm#),2(0.018cm,0cm#),3(-0.018cm,0cm#)'
 | psnup -2 -d -p a4 -P a5 
 | pstops '2:0,1U(21cm,29.7cm)'
Note that there are 4 sides printed on each piece of paper in this example.