The attached patch xpdf-zoom-height.patch implements a "fit height" zoom mode for xpdf. It includes a new hotkey 'h', a new value "height" for the relevant command-line and configuration-file options, a new command zoomFitHeight for use in xpdfrc bindings, and documentation updates for all of these.
The attached patch xpdf-zoom-height-debian.patch adjusts a Debian patch to still apply after my manpage updates. I've tested the resulting packages, and they work well for me. Note that I did not update the manpage .cat or .hlp files for the changes to the source files; the makefile includes no rules to build those files, and I didn't see any documentation for the right way to build them without generating spurious differences. - Josh Triplett
diff -Naur xpdf-3.02.orig/doc/xpdf.1 xpdf-3.02/doc/xpdf.1
--- xpdf-3.02.orig/doc/xpdf.1 2007-02-27 14:05:51.000000000 -0800
+++ xpdf-3.02/doc/xpdf.1 2007-05-15 14:51:13.000000000 -0700
@@ -92,9 +92,9 @@
.TP
.BI \-z " zoom"
Set the initial zoom factor. A number specifies a zoom percentage,
-where 100 means 72 dpi.You may also specify \'page', to fit the page
-to the window size, or \'width', to fit the page width to the window
-width.
+where 100 means 72 dpi. You may also specify \'page', to fit the page
+to the window size, \'width', to fit the page width to the window width,
+or \'height', to fit the page height to the window height.
.RB "[config file: " initialZoom "; or X resource: " xpdf.initialZoom ]
.TP
.B \-cont
@@ -423,6 +423,9 @@
.B w
Set the zoom factor to 'width' (fit page width to window).
.TP
+.B h
+Set the zoom factor to 'height' (fit page height to window).
+.TP
.B alt-F
Toggle full-screen mode.
.TP
@@ -575,6 +578,9 @@
.B zoomFitWidth
Set the zoom factor to fit-width.
.TP
+.B zoomFitHeight
+Set the zoom factor to fit-height.
+.TP
.B zoomIn
Zoom in - go to the next higher zoom factor.
.TP
@@ -783,6 +789,7 @@
bind - any zoomOut
bind z any zoomFitPage
bind w any zoomFitWidth
+ bind h any zoomFitHeight
bind alt-f any toggleFullScreenMode
bind ctrl-l any redraw
bind ctrl-w any closeWindow
diff -Naur xpdf-3.02.orig/doc/xpdfrc.5 xpdf-3.02/doc/xpdfrc.5
--- xpdf-3.02.orig/doc/xpdfrc.5 2007-02-27 14:05:51.000000000 -0800
+++ xpdf-3.02/doc/xpdfrc.5 2007-05-15 14:49:01.000000000 -0700
@@ -362,11 +362,11 @@
cross-hatching. This defaults to "no".
.SH MISCELLANEOUS SETTINGS
.TP
-.BR initialZoom " \fIpercentage\fR | page | width"
+.BR initialZoom " \fIpercentage\fR | page | width | height"
Sets the initial zoom factor. A number specifies a zoom percentage,
where 100 means 72 dpi. You may also specify \'page', to fit the page
-to the window size, or \'width', to fit the page width to the window
-width.
+to the window size, \'width', to fit the page width to the window width,
+or \'height', to fit the page height to the window height.
.TP
.BR continuousView " yes | no"
If set to "yes", xpdf will start in continuous view mode, i.e., with
diff -Naur xpdf-3.02.orig/xpdf/GlobalParams.cc xpdf-3.02/xpdf/GlobalParams.cc
--- xpdf-3.02.orig/xpdf/GlobalParams.cc 2007-02-27 14:05:52.000000000 -0800
+++ xpdf-3.02/xpdf/GlobalParams.cc 2007-05-15 14:18:47.000000000 -0700
@@ -895,6 +895,8 @@
xpdfKeyContextAny, "zoomFitPage"));
keyBindings->append(new KeyBinding('w', xpdfKeyModNone,
xpdfKeyContextAny, "zoomFitWidth"));
+ keyBindings->append(new KeyBinding('h', xpdfKeyModNone,
+ xpdfKeyContextAny, "zoomFitHeight"));
keyBindings->append(new KeyBinding('f', xpdfKeyModAlt,
xpdfKeyContextAny,
"toggleFullScreenMode"));
diff -Naur xpdf-3.02.orig/xpdf/PDFCore.cc xpdf-3.02/xpdf/PDFCore.cc
--- xpdf-3.02.orig/xpdf/PDFCore.cc 2007-02-27 14:05:52.000000000 -0800
+++ xpdf-3.02/xpdf/PDFCore.cc 2007-05-15 14:09:54.000000000 -0700
@@ -431,6 +431,12 @@
dpiA = (hDPI < vDPI) ? hDPI : vDPI;
} else if (zoomA == zoomWidth) {
dpiA = (drawAreaWidth / uw) * 72;
+ } else if (zoomA == zoomHeight) {
+ if (continuousMode) {
+ dpiA = ((drawAreaHeight - continuousModePageSpacing) / uh) * 72;
+ } else {
+ dpiA = (drawAreaHeight / uh) * 72;
+ }
} else {
dpiA = 0.01 * zoomA * 72;
}
@@ -1160,6 +1166,24 @@
dpi1 = 72.0 * (double)drawAreaWidth / pageW;
sx = 0;
+ } else if (zoomA == zoomHeight) {
+ if (continuousMode) {
+ pageH = (rotate == 90 || rotate == 270) ? maxUnscaledPageW
+ : maxUnscaledPageH;
+ dpi1 = 72.0 * (double)(drawAreaHeight - continuousModePageSpacing) / pageH;
+ } else {
+ rot = rotate + doc->getPageRotate(topPage);
+ if (rot >= 360) {
+ rot -= 360;
+ } else if (rot < 0) {
+ rot += 360;
+ }
+ pageH = (rot == 90 || rot == 270) ? doc->getPageCropWidth(topPage)
+ : doc->getPageCropHeight(topPage);
+ dpi1 = 72.0 * (double)drawAreaHeight / pageH;
+ }
+ sx = 0;
+
} else if (zoomA <= 0) {
return;
diff -Naur xpdf-3.02.orig/xpdf/PDFCore.h xpdf-3.02/xpdf/PDFCore.h
--- xpdf-3.02.orig/xpdf/PDFCore.h 2007-02-27 14:05:52.000000000 -0800
+++ xpdf-3.02/xpdf/PDFCore.h 2007-05-15 14:10:18.000000000 -0700
@@ -37,9 +37,10 @@
// zoom factor
//------------------------------------------------------------------------
-#define zoomPage -1
-#define zoomWidth -2
-#define defZoom 125
+#define zoomPage -1
+#define zoomWidth -2
+#define zoomHeight -3
+#define defZoom 125
//------------------------------------------------------------------------
diff -Naur xpdf-3.02.orig/xpdf/XPDFCore.cc xpdf-3.02/xpdf/XPDFCore.cc
--- xpdf-3.02.orig/xpdf/XPDFCore.cc 2007-02-27 14:05:52.000000000 -0800
+++ xpdf-3.02/xpdf/XPDFCore.cc 2007-05-15 14:12:04.000000000 -0700
@@ -118,6 +118,8 @@
zoom = zoomPage;
} else if (!initialZoom->cmp("width")) {
zoom = zoomWidth;
+ } else if (!initialZoom->cmp("height")) {
+ zoom = zoomHeight;
} else {
zoom = atoi(initialZoom->getCString());
if (zoom <= 0) {
@@ -246,7 +248,7 @@
width1 = doc->getPageCropWidth(pg);
height1 = doc->getPageCropHeight(pg);
}
- if (zoom == zoomPage || zoom == zoomWidth) {
+ if (zoom == zoomPage || zoom == zoomWidth || zoom == zoomHeight) {
width = (Dimension)(width1 * 0.01 * defZoom + 0.5);
height = (Dimension)(height1 * 0.01 * defZoom + 0.5);
} else {
@@ -1028,7 +1030,7 @@
XtGetValues(core->drawArea, args, n);
core->drawAreaWidth = (int)w;
core->drawAreaHeight = (int)h;
- if (core->zoom == zoomPage || core->zoom == zoomWidth) {
+ if (core->zoom == zoomPage || core->zoom == zoomWidth || core->zoom == zoomHeight) {
sx = sy = -1;
} else {
sx = core->scrollX;
diff -Naur xpdf-3.02.orig/xpdf/XPDFViewer.cc xpdf-3.02/xpdf/XPDFViewer.cc
--- xpdf-3.02.orig/xpdf/XPDFViewer.cc 2007-02-27 14:05:52.000000000 -0800
+++ xpdf-3.02/xpdf/XPDFViewer.cc 2007-05-15 14:38:42.000000000 -0700
@@ -139,23 +139,25 @@
};
static ZoomMenuInfo zoomMenuInfo[nZoomMenuItems] = {
- { "400%", 400 },
- { "200%", 200 },
- { "150%", 150 },
- { "125%", 125 },
- { "100%", 100 },
- { "50%", 50 },
- { "25%", 25 },
- { "12.5%", 12.5 },
- { "fit page", zoomPage },
- { "fit width", zoomWidth }
+ { "400%", 400 },
+ { "200%", 200 },
+ { "150%", 150 },
+ { "125%", 125 },
+ { "100%", 100 },
+ { "50%", 50 },
+ { "25%", 25 },
+ { "12.5%", 12.5 },
+ { "fit page", zoomPage },
+ { "fit width", zoomWidth },
+ { "fit height", zoomHeight }
};
-#define maxZoomIdx 0
-#define defZoomIdx 3
-#define minZoomIdx 7
-#define zoomPageIdx 8
-#define zoomWidthIdx 9
+#define maxZoomIdx 0
+#define defZoomIdx 3
+#define minZoomIdx 7
+#define zoomPageIdx 8
+#define zoomWidthIdx 9
+#define zoomHeightIdx 10
//------------------------------------------------------------------------
@@ -229,6 +231,7 @@
{ "windowMode", 0, gFalse, gFalse, &XPDFViewer::cmdWindowMode },
{ "zoomFitPage", 0, gFalse, gFalse, &XPDFViewer::cmdZoomFitPage },
{ "zoomFitWidth", 0, gFalse, gFalse, &XPDFViewer::cmdZoomFitWidth },
+ { "zoomFitHeight", 0, gFalse, gFalse, &XPDFViewer::cmdZoomFitHeight },
{ "zoomIn", 0, gFalse, gFalse, &XPDFViewer::cmdZoomIn },
{ "zoomOut", 0, gFalse, gFalse, &XPDFViewer::cmdZoomOut },
{ "zoomPercent", 1, gFalse, gFalse, &XPDFViewer::cmdZoomPercent },
@@ -1345,6 +1348,15 @@
}
}
+void XPDFViewer::cmdZoomFitHeight(GString *args[], int nArgs,
+ XEvent *event) {
+ if (core->getZoom() != zoomHeight) {
+ setZoomIdx(zoomHeightIdx);
+ displayPage(core->getPageNum(), zoomHeight,
+ core->getRotate(), gTrue, gFalse);
+ }
+}
+
void XPDFViewer::cmdZoomIn(GString *args[], int nArgs,
XEvent *event) {
int z;
diff -Naur xpdf-3.02.orig/xpdf/XPDFViewer.h xpdf-3.02/xpdf/XPDFViewer.h
--- xpdf-3.02.orig/xpdf/XPDFViewer.h 2007-02-27 14:05:52.000000000 -0800
+++ xpdf-3.02/xpdf/XPDFViewer.h 2007-05-15 14:38:52.000000000 -0700
@@ -41,7 +41,7 @@
//------------------------------------------------------------------------
// NB: this must match the defn of zoomMenuBtnInfo in XPDFViewer.cc
-#define nZoomMenuItems 10
+#define nZoomMenuItems 11
//------------------------------------------------------------------------
@@ -167,6 +167,7 @@
void cmdWindowMode(GString *args[], int nArgs, XEvent *event);
void cmdZoomFitPage(GString *args[], int nArgs, XEvent *event);
void cmdZoomFitWidth(GString *args[], int nArgs, XEvent *event);
+ void cmdZoomFitHeight(GString *args[], int nArgs, XEvent *event);
void cmdZoomIn(GString *args[], int nArgs, XEvent *event);
void cmdZoomOut(GString *args[], int nArgs, XEvent *event);
void cmdZoomPercent(GString *args[], int nArgs, XEvent *event);
diff -Naur xpdf-3.02.orig/xpdf/about-text.h xpdf-3.02/xpdf/about-text.h
--- xpdf-3.02.orig/xpdf/about-text.h 2007-02-27 14:05:52.000000000 -0800
+++ xpdf-3.02/xpdf/about-text.h 2007-05-15 14:44:18.000000000 -0700
@@ -36,7 +36,7 @@
" v = forward (history path)",
" b = backward (history path)",
" 0 / + / - = zoom zero / in / out",
- " z / w = zoom page / page width",
+ " z / w / h = zoom page / page width / page height",
" alt-F = toggle full-screen mode",
" ctrl-L = redraw",
" q = quit",
--- xpdf-3.02.orig/debian/patches/01_manpage.dpatch 2007-05-15 13:59:36.000000000 -0700 +++ xpdf-3.02/debian/patches/01_manpage.dpatch 2007-05-15 15:07:54.000000000 -0700 @@ -148,17 +148,19 @@ .BR xpdfrc (5) man page for details. .SH OPTIONS -@@ -92,8 +103,8 @@ +@@ -92,9 +103,9 @@ .TP .BI \-z " zoom" Set the initial zoom factor. A number specifies a zoom percentage, --where 100 means 72 dpi.You may also specify \'page', to fit the page --to the window size, or \'width', to fit the page width to the window -+where 100 means 72 dpi.You may also specify 'page', to fit the page -+to the window size, or 'width', to fit the page width to the window - width. +-where 100 means 72 dpi. You may also specify \'page', to fit the page +-to the window size, \'width', to fit the page width to the window width, +-or \'height', to fit the page height to the window height. ++where 100 means 72 dpi. You may also specify 'page', to fit the page ++to the window size, 'width', to fit the page width to the window width, ++or 'height', to fit the page height to the window height. .RB "[config file: " initialZoom "; or X resource: " xpdf.initialZoom ] .TP + .B \-cont @@ -123,7 +134,7 @@ .BI \-ps " PS-file" Set the default file name for PostScript output (i.e., the name which
signature.asc
Description: OpenPGP digital signature

