summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-11-07 16:46:54 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-11-07 16:50:31 -0800
commit6f34ba3a67e2c25f4fd6b2878038793422bf8770 (patch)
treec7217904128a8d2ee9362db09eb8ef19828e280c
parent24c71e04d248f06337f7885dc5642d720a087ba9 (diff)
Add support for paper sizes other than 8.5 x 11 inches
This adds new command line arguments -papertype, -pheight, and -pwidth Originally implemented by Jay Hobson in August 2002 to fix Sun bug 4704388: xpr does not work with A3 paper Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--COPYING21
-rw-r--r--x2jet.c3
-rw-r--r--xpr.c159
-rw-r--r--xpr.man132
4 files changed, 301 insertions, 14 deletions
diff --git a/COPYING b/COPYING
index 0f9d8e0..0bde13b 100644
--- a/COPYING
+++ b/COPYING
@@ -1,3 +1,24 @@
+Copyright (c) 2002, Oracle and/or its affiliates.
+
+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.
+
Copyright (c) 1985, 1988 X Consortium
diff --git a/x2jet.c b/x2jet.c
index 55b8f0d..2475c67 100644
--- a/x2jet.c
+++ b/x2jet.c
@@ -1285,7 +1285,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 ccf064c..86cf107 100644
--- a/xpr.c
+++ b/xpr.c
@@ -69,6 +69,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.
+ *
+ * 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.
*/
#ifdef HAVE_CONFIG_H
@@ -115,6 +138,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 */
@@ -155,6 +181,51 @@ 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
*/
@@ -192,7 +263,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,
@@ -204,7 +277,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,
@@ -227,7 +302,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 ps_output_bits(
int iw,
@@ -273,6 +350,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";
@@ -281,7 +362,12 @@ 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,
@@ -370,13 +456,14 @@ 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);
iw = win.pixmap_width;
ih = win.pixmap_height;
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();
@@ -428,6 +515,8 @@ usage(void)
" -landscape -portrait\n"
" -left <inches> -top <inches>\n"
" -noposition\n"
+ " -papertype {letter | legal | A0-A10 | B0-B10 | C0-C10}\n"
+ " -pheight <inches>[in | cm | mm] -pwidth <inches>[in | cm | mm]\n"
" -plane <n>\n"
" -psfig\n"
" -render <type>\n"
@@ -460,7 +549,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;
@@ -568,12 +659,48 @@ void parse_args(
output_filename = *argv;
} else if (!strcmp(*argv, "-portrait")) {
*flags |= F_PORTRAIT;
+ } else if (!strcmp(*argv, "-papertype")) {
+ int found = 0;
+ int i;
+
+ argc--; argv++;
+ if (argc == 0) missing_arg(arg);
+ 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 (!strcmp(*argv, "-plane")) {
argc--; argv++;
if (argc == 0) missing_arg(arg);
*plane = atoi(*argv);
} else if (!strcmp(*argv, "-psfig")) {
*flags |= F_NPOSITION;
+ } else if (!strcmp(*argv, "-pwidth")) {
+ double mult = 1.0;
+
+ argc--; argv++;
+ if (argc == 0) missing_arg(arg);
+ 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 (!strcmp(*argv, "-pheight")) {
+ double mult = 1.0;
+
+ argc--; argv++;
+ if (argc == 0) missing_arg(arg);
+ if ( strstr ( *argv, "cm" ))
+ mult = 2.54;
+ else if ( strstr ( *argv, "mm" ))
+ mult = 25.4;
+ *paper_length = (int)(300.0 * atof(*argv) / mult);
} else if (!strcmp(*argv, "-rv")) {
*flags |= F_INVERT;
} else if (!strcmp(*argv, "-render")) {
@@ -660,7 +787,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;
@@ -676,22 +805,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 {
*orientation = PORTRAIT;
- *scale = W_MAX / win_width;
+ *scale = wmax / win_width;
}
if (*scale == 0) *scale = 1;
if (*scale > 6) *scale = 6;
@@ -1072,7 +1201,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
diff --git a/xpr.man b/xpr.man
index 05e03f3..917630e 100644
--- a/xpr.man
+++ b/xpr.man
@@ -52,6 +52,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
@@ -176,6 +189,125 @@ 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\-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.
.IP "\fB\-density\fP \fIdpi\fP"