diff --git a/x2jet.c b/x2jet.c
index 3246c33..1c9a1c4 100644
--- a/x2jet.c
+++ b/x2jet.c
@@ -1279,7 +1279,10 @@ void write_image_suffix (
if (device == PJETXL)
fprintf(out,"\033*rC");
else
+ {
fprintf(out,"\033*rB");
+ fprintf(out,"\033E");
+ }
/* If doing transparencies, tell it to stop */
if (slide && device != LJET)
diff --git a/xpr.c b/xpr.c
index b9cd707..9865c7e 100644
--- a/xpr.c
+++ b/xpr.c
@@ -70,6 +70,29 @@ from the X Consortium.
* to devices recognized. Also added -density, -cutoff, and -noposition
* command line options.
*
+ * Modified by Jay Hobson, Sun Microsystems to support paper sizes other
+ * than 8.5x11 inches.
+ *
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
*/
#include <X11/Xos.h>
@@ -113,6 +136,9 @@ int debug = 0;
#define W_PAGE 2550
#define H_PAGE 3225
+#define PAPER_WIDTH 85*30 /* 8.5 inches */
+#define PAPER_LENGTH 11*300 /* 11 inches */
+
#ifdef NOINLINE
#define min(x,y) (((x)<(y))?(x):(y))
#endif /* NOINLINE */
@@ -154,6 +180,50 @@ static GrayRec gray2x2 = {sizeof(grayscale2x2)/sizeof(long), 2, 2, grayscale2x2}
static GrayRec gray3x3 = {sizeof(grayscale3x3)/sizeof(long), 3, 3, grayscale3x3};
static GrayRec gray4x4 = {sizeof(grayscale4x4)/sizeof(long), 4, 4, grayscale4x4};
+typedef struct {
+ char *name;
+ double width;
+ double length;
+} PaperRec;
+
+PaperRec paper_size[] = {
+ {"Letter", 8.5, 11.0 },
+ {"Legal", 8.5, 14.0 },
+ {"A0", 33.11, 46.81},
+ {"A1", 23.39, 33.11},
+ {"A2", 16.5, 23.39},
+ {"A3", 11.7, 16.5 },
+ {"A4", 8.27, 11.7 },
+ {"A5", 5.83, 8.27},
+ {"A6", 4.13, 5.83},
+ {"A7", 2.91, 4.13},
+ {"A8", 2.05, 2.91},
+ {"A9", 1.46, 2.05},
+ {"A10", 1.02, 1.46},
+ {"B0", 39.37, 55.67},
+ {"B1", 27.83, 39.37},
+ {"B2", 19.69, 27.83},
+ {"B3", 13.90, 19.69},
+ {"B4", 9.84, 13.90},
+ {"B5", 6.93, 9.84},
+ {"B6", 4.92, 6.93},
+ {"B7", 3.46, 4.92},
+ {"B8", 2.44, 3.46},
+ {"B9", 1.73, 2.44},
+ {"B10", 1.22, 1.73},
+ {"C0", 36.10, 51.06},
+ {"C1", 25.51, 36.10},
+ {"C2", 18.03, 25.51},
+ {"C3", 12.76, 18.03},
+ {"C4", 9.02, 12.76},
+ {"C5", 6.38, 9.02},
+ {"C6", 4.49, 6.38},
+ {"C7", 3.19, 4.49},
+ {"C8", 2.24, 3.19},
+ {"C9", 1.57, 2.24},
+ {"C10", 1.10, 1.57}};
+
+
/* mapping tables to map a byte in to the hex representation of its
* bit-reversal
*/
@@ -191,7 +261,9 @@ void parse_args(
int *density,
unsigned int *cutoff,
float *gamma,
- int *render);
+ int *render,
+ int *paper_width,
+ int *paper_length);
static
void setup_layout(
enum device device,
@@ -203,7 +275,9 @@ void setup_layout(
char *header,
char *trailer,
int *scale,
- enum orientation *orientation);
+ enum orientation *orientation,
+ int wmax,
+ int hmax);
static
char *convert_data(
XWDFileHeader *win,
@@ -237,7 +311,9 @@ void ln03_setup(
int *top_margin,
int flags,
const char *header,
- const char *trailer);
+ const char *trailer,
+ int paper_width,
+ int paper_length);
static void ln03_finish(void);
static void la100_setup(int iw, int ih, int scale);
static void la100_finish(void);
@@ -255,7 +331,9 @@ void ps_setup(
int flags,
const char *header,
const char *trailer,
- const char *name);
+ const char *name,
+ int paper_width,
+ int paper_length);
static void ps_finish(void);
static
void ln03_output_sixels(
@@ -320,6 +398,10 @@ int main(int argc, char **argv)
enum orientation orientation;
enum device device;
XColor *colors = (XColor *)NULL;
+ int paper_width = PAPER_WIDTH;
+ int paper_length = PAPER_LENGTH;
+ int w_max = W_MAX;
+ int h_max = W_MAX;
if (!(progname = argv[0]))
progname = "xpr";
@@ -328,7 +410,14 @@ int main(int argc, char **argv)
#endif
parse_args (argc, argv, &scale, &width, &height, &left, &top, &device,
&flags, &split, &header, &trailer, &plane, &gray,
- &density, &cutoff, &gamma, &render);
+ &density, &cutoff, &gamma, &render, &paper_width, &paper_length);
+
+ if (paper_width != PAPER_WIDTH)
+ w_max = paper_width - 150;
+ if (paper_length != PAPER_LENGTH)
+ h_max = paper_length - 150;
+
+
if (device == PP) {
x2pmp(stdin, stdout, scale,
@@ -414,7 +503,8 @@ int main(int argc, char **argv)
/* calculate orientation and scale */
setup_layout(device, (int) win.pixmap_width, (int) win.pixmap_height,
- flags, width, height, header, trailer, &scale, &orientation);
+ flags, width, height, header, trailer, &scale, &orientation,
+ w_max, h_max);
if (device == PS) {
iw = win.pixmap_width;
@@ -436,7 +526,7 @@ int main(int argc, char **argv)
if (device == LN03) {
/* ln03_grind_fonts(sixmap, iw, ih, scale, &pixmap); */
ln03_setup(iw, ih, orientation, scale, left, top,
- &left_margin, &top_margin, flags, header, trailer);
+ &left_margin, &top_margin, flags, header, trailer, paper_width, paper_length);
ln03_output_sixels(sixmap, iw, ih, (flags & F_NOSIXOPT), split,
scale, top_margin, left_margin);
ln03_finish();
@@ -446,7 +536,7 @@ int main(int argc, char **argv)
la100_finish();
} else if (device == PS) {
ps_setup(iw, ih, orientation, scale, left, top,
- flags, header, trailer, w_name);
+ flags, header, trailer, w_name, paper_width, paper_length);
ps_output_bits(iw, ih, flags, orientation, &win, data);
ps_finish();
} else {
@@ -482,6 +572,8 @@ void usage(void)
fprintf(stderr, " -left <inches> -top <inches>\n");
fprintf(stderr, " -noposition\n");
fprintf(stderr, " -nosixopt\n");
+ fprintf(stderr, " -papertype {letter | legal | A0-A10 | B0-B10 | C0-C10}\n");
+ fprintf(stderr, " -pheight <inches>[in | cm | mm] -pwidth <inches>[in | cm | mm]\n");
fprintf(stderr, " -plane <n>\n");
fprintf(stderr, " -psfig\n");
fprintf(stderr, " -render <type>\n");
@@ -512,7 +604,9 @@ void parse_args(
int *density,
unsigned int *cutoff,
float *gamma,
- int *render)
+ int *render,
+ int *paper_width,
+ int *paper_length)
{
register char *output_filename;
register int f;
@@ -685,17 +779,54 @@ void parse_args(
usage();
break;
- case 'p': /* -portrait | -plane <n> */
+ case 'p': /* -portrait | -plane <n> | -pwidth <n> | -pheight <n> */
if (len <= 2)
usage();
if (!bcmp(*argv, "-portrait", len)) {
*flags |= F_PORTRAIT;
+ } else if (!bcmp(*argv, "-papertype", len)) {
+ int found = 0;
+ int i;
+
+ argc--; argv++;
+ if (argc == 0) usage();
+ for ( i = 0; i < sizeof ( paper_size ) / sizeof ( PaperRec ); i++ )
+ {
+ if ( !strcasecmp ( paper_size[i].name, *argv ))
+ {
+ found = 1;
+ *paper_width = (int)(300.0 * paper_size[i].width);
+ *paper_length = (int)(300.0 * paper_size[i].length);
+ }
+ }
+
+ if ( !found ) usage();
} else if (!bcmp(*argv, "-plane", len)) {
argc--; argv++;
if (argc == 0) usage();
*plane = atoi(*argv);
} else if (!bcmp(*argv, "-psfig", len)) {
*flags |= F_NPOSITION;
+ } else if (!bcmp(*argv, "-pwidth", len)) {
+ double mult = 1.0;
+
+ argc--; argv++;
+ if (argc == 0) usage();
+ if ( strstr ( *argv, "cm" ))
+ mult = 2.54;
+ else if ( strstr ( *argv, "mm" ))
+ mult = 25.4;
+ *paper_width = (int)(300.0 * atof(*argv) / mult);
+ } else if (!bcmp(*argv, "-pheight", len)) {
+ double mult = 1.0;
+
+ argc--; argv++;
+ if (argc == 0) usage();
+ if ( strstr ( *argv, "cm" ))
+ mult = 2.54;
+ else if ( strstr ( *argv, "mm" ))
+ mult = 25.4;
+ *paper_length = (int)(300.0 * atof(*argv) / mult);
} else
usage();
break;
@@ -813,7 +944,9 @@ void setup_layout(
char *header,
char *trailer,
int *scale,
- enum orientation *orientation)
+ enum orientation *orientation,
+ int wmax,
+ int hmax)
{
register int w_scale;
register int h_scale;
@@ -829,22 +962,22 @@ void setup_layout(
if ((win_width < win_height || (flags & F_PORTRAIT)) &&
!(flags & F_LANDSCAPE)) {
*orientation = PORTRAIT;
- w_max = (width > 0)? width : W_MAX;
- h_max = (height > 0)? height : H_MAX;
+ w_max = (width > 0)? width : wmax;
+ h_max = (height > 0)? height : hmax;
w_scale = w_max / win_width;
h_scale = h_max / win_height;
*scale = min(w_scale, h_scale);
} else {
*orientation = LANDSCAPE;
- w_max = (width > 0)? width : H_MAX;
- h_max = (height > 0)? height : W_MAX;
+ w_max = (width > 0)? width : hmax;
+ h_max = (height > 0)? height : wmax;
w_scale = w_max / win_width;
h_scale = h_max / win_height;
*scale = min(w_scale, h_scale);
}
} else { /* device == LA100 */
*orientation = PORTRAIT;
- *scale = W_MAX / win_width;
+ *scale = wmax / win_width;
}
if (*scale == 0) *scale = 1;
if (*scale > 6) *scale = 6;
@@ -1151,7 +1284,9 @@ void ln03_setup(
int *top_margin,
int flags,
const char *header,
- const char *trailer)
+ const char *trailer,
+ int paper_width,
+ int paper_length)
{
register int i;
register int lm, tm, xm;
@@ -1432,7 +1567,9 @@ void ps_setup(
int flags,
const char *header,
const char *trailer,
- const char *name)
+ const char *name,
+ int paper_width,
+ int paper_length)
{
char hostname[256];
#ifdef WIN32
@@ -1546,7 +1683,7 @@ char *ps_epilog[] = {
static
void ps_finish(void)
{
- char **p = (char **)ps_epilog;
+ const char **p = ps_epilog;
while (*p) printf("%s\n",*p++);
}
diff --git a/xpr.man b/xpr.man
index 3129f08..223f037 100644
--- a/xpr.man
+++ b/xpr.man
@@ -53,6 +53,19 @@ xpr \- print an X window dump
.B \-split
.I n
] [
+.B \-papertype
+.I format
+] [
+.B \-pheight
+.I inches
+[
+.I units
+]] [
+.B \-pwidth
+.I inches
+[
+.I units
+]] [
.B \-psfig
] [
.B \-density
@@ -181,8 +194,127 @@ on the same page as the previous window.
This option allows the user to split a window onto several pages.
This might be necessary for very large windows that would otherwise
cause the printer to overload and print the page in an obscure manner.
-.IP "\fB\-psfig\fP"
-Suppress translation of the PostScript picture to the center of the page.
+.IP "\fB\-papertype\fP \fIformat\fP"
+Specifies the output paper format. Currently supported:
+.RS 12
+.PD 0
+.TP
+.B letter
+letter size 8.5x11 inches
+.TP
+.B legal
+legal size 8.5x14 inches
+.TP
+.B A0
+A0 size 841x1189 mm or 33.11x46.81 inches
+.TP
+.B A1
+A1 size 594x841 mm or 23.39x33.11 inches
+.TP
+.B A2
+A2 size 420x594 mm or 16.54x23.39 inches
+.TP
+.B A3
+A3 size 297x420 mm or 11.69x16.54 inches
+.TP
+.B A4
+A4 size 210x297 mm or 8.27x11.69 inches
+.TP
+.B A5
+A5 size 148x210 mm or 5.83x 8.27 inches
+.TP
+.B A6
+A6 size 105x148 mm or 4.13x 5.83 inches
+.TP
+.B A7
+A7 size 74x105 mm or 2.91x 4.13 inches
+.TP
+.B A8
+A8 size 52x74 mm or 2.05x 2.91 inches
+.TP
+.B A9
+A9 size 37x52 mm or 1.46x 2.05 inches
+.TP
+.B A10
+A10 size 26x37 mm or 1.02x 1.46 inches
+.TP
+.B B0
+B0 size 1000x1414 mm or 39.37x55.67
+.TP
+.B B1
+B1 size 707x1000 mm or 27.83x39.37 inches
+.TP
+.B B2
+B2 size 500x707 mm or 19.69x27.83 inches
+.TP
+.B B3
+B3 size 353x500 mm or 13.90x19.69 inches
+.TP
+.B B4
+B4 size 250x353 mm or 9.84x13.90 inches
+.TP
+.B B5
+B5 size 176x250 mm or 6.93x 9.84 inches
+.TP
+.B B6
+B6 size 125x176 mm or 4.92x 6.93 inches
+.TP
+.B B7
+B7 size 88x125 mm or 3.46x 4.92 inches
+.TP
+.B B8
+B8 size 62x88 mm or 2.44x 3.46 inches
+.TP
+.B B9
+B9 size 44x62 mm or 1.73x 2.44 inches
+.TP
+.B B10
+B10 size 31x44 mm or 1.22x 1.73 inches
+.TP
+.B C0
+C0 size 917x1297 mm or 36.10x51.06 inches
+.TP
+.B C1
+C1 size 648x917 mm or 25.51x36.10 inches
+.TP
+.B C2
+C2 size 458x648 mm or 18.03x25.51 inches
+.TP
+.B C3
+C3 size 324x458 mm or 12.76x18.03 inches
+.TP
+.B C4
+C4 size 229x324 mm or 9.02x12.76 inches
+.TP
+.B C5
+C5 size 162x229 mm or 6.38x 9.02 inches
+.TP
+.B C6
+C6 size 114x162 mm or 4.49x 6.38 inches
+.TP
+.B C7
+C7 size 81x114 mm or 3.19x 4.49 inches
+.TP
+.B C8
+C8 size 57x81 mm or 2.24x 3.19 inches
+.TP
+.B C9
+C9 size 40x57 mm or 1.57x 2.24 inches
+.TP
+.B C10
+C10 size 28x40 mm or 1.10x 1.57 inches
+.PD
+.RE
+.IP "\fB\-pheight\fP \fIinches\fP [ \fIunits\fP ]"
+This option allows the user to specify a specific paper height. The
+default units are in inches (in), but may be overridden with cm or mm
+for centimeters or millimeters respectively.
+.IP "\fB\-pwidth\fP \fIinches\fP [ \fIunits\fP ]"
+This option allows the user to specify a specific paper width. The
+default units are in inches (in), but may be overridden with cm or mm
+for centimeters or millimeters respectively.
+ .IP "\fB\-psfig\fP"
+Suppress translation of the PostScript picture to the center of the page. \fI \fP
.IP "\fB\-density\fP \fIdpi\fP"
Indicates what dot-per-inch density should be used by the HP printer.
.IP "\fB\-cutoff\fP \fIlevel\fP"