March 18, 2012

Controlled Rotation when PDF File is Opened

There are online services that provide books viewed through a browser with a PDF viewer plugin. Wholesale copying is hindered by serving each page as a separate PDF file, where the plugin closes and reopens each time a new page is viewed. While a bit of a kludge, it works fairly well, except when a reader wants to rotate all of the pages and their device doesn't support display rotation.

I wanted to view all of the pages of such a book rotated 90° on a laptop display held sideways, thereby to reduce scrolling. Unfortunately, the particular laptop was an older model that didn't support display rotation.* Rotating the PDF in the plugin worked for a page, but the rotation didn't hold between pages since the plugin was loaded with each turn of the page. Consequently, annoying keypresses or mouse clicks were needed to rotate each new page.

Searching for a PDF viewer with any option to set the initial rotation when opening a file was fruitless. But I did find an open source PDF viewer called Xpdf that had just about every startup option you'd want except rotation. Finding nothing better to serve the purpose, I decided to add the option myself.

Having ran across others looking in vain for the same functionality during my search, I decided to put up a patch in hopes of helping at least somebody out there. My Rotation Control Patch to add rotation options to Xpdf is freely available at http://sourceforge.net/projects/xpdf-rcpatch/, and updated manpages are also available in the files section. The latest version of the source code for Xpdf itself is freely available from http://www.foolabs.com/xpdf/. Note that Xpdf can be compiled to run on a number of other operating systems than Linux, including Windows.

There was one significant problem I ran into when building Xpdf. A note in the INSTALL file accompanying the Xpdf source reads:
(The include path is the directory which contains the freetype2 directory, i.e., do NOT include "freetype2" in the --with-freetype2-includes path. For example, with the default installation, the library path is /usr/local/lib and the include path is /usr/local/include/freetype2.)
This doesn't seem to make sense. After stating, with EMPHASIS, that freetype2 shouldn't be included in the include path, it goes on to show an example where the include path includes freetype2. To complicate matters, my distro didn't install freetype2 in /usr/local, a fact I didn't realize until after a bit of head banging. In the end, the configure line that worked for me was:
./configure --with-freetype2-library=/usr/lib --with-freetype2-includes=/usr/include/freetype2 --with-Xm-library=/usr/lib --with-Xm-includes=/usr/include/Xm
Your mileage may vary.

* It may instead have been the display driver I had to use, since no Linux driver was available from the manufacturer, but I'm not reloading Win98 on it to find out. :)

March 13, 2012

Suppress diff Missing File Messages

To suppress the missing file messages diff generates when creating a patch for multiple files, just filter them out with grep.  For example:
diff -rc olddir newdir | grep -v -e "^Only in" > diffs.patch

March 11, 2012

Solved: XP Repair Install Hanging at Installing Network

A Repair Install is required to get a hard drive with XP to boot after being moved to a new computer. However, it's apparently not uncommon for the Repair Install to hang somewhere in the process.

In my case of moving a hard drive with a retail version of XP installed from one computer to another, the Repair Install hung upon reaching "Installing Network" at about 31 minutes left in the install. To get around this problem, I did the following:
  • Hit Shift + F10 to open a command prompt.
  • Ran taskmgr.exe to bring up the Task Manager.
  • Examined the Processes and found spoolsv.exe, the "Print Spooler" service, to be consuming practically all of the CPU time.
  • Returned to the command prompt and ran services.msc to get to the Services window.
  • Clicked the Standard tab.
  • Located Print Spooler and right-clicked on it.
  • Selected Stop in the popup menu.
...and the Repair Install resumed immediately after the Print Spooler service was stopped.

The Repair Install hung once again later in the process around 9 minutes left. Task Manager showed that the spoolsv.exe was again hogging all of the CPU time. Repeating the Print Spooler stop again got the Repair Install to immediately resume, and it then continued to completion uninterrupted.

This solution was the result of a lot of searching and followed many unsuccessful attempts involving hardware changes, BIOS configuration changes, and software removal. Kudos to the people who posted the content on the following pages, from which my solution was pieced together:

Changing a Motherboard or Moving a Hard Drive with XP Installed

xp repair reinstall hangs at Installing Network (Microsoft XP)

What is the Windows spoolsv.exe file / process?

Run Command Shortcuts for Administrative Tools