Random Wisdom

Tag: printing

Printing to a Windows GDI printer from Linux

by on Feb.20, 2012, under Hardware, How To ..., Linux

Quite a few of the cheaper laser printers are difficult to use directly on Linux due to missing drivers. The reason is that quite a bit of the work is actually done by the (Windows) driver rather than the printer itself. These printers have come be known as GDI or Winprinters. The EPSON AcuLaser C1750 is such a printer. After struggling for a few days, trying to get it to work natively under Linux, I decided to look for an alternative solution [Update: see bottom of article]. Then I found one.

The basic idea is to create a dummy shared PS printer on a Windows host and then also install the physical printer there. The dummy printer accepts PS jobs from Linux clients and then filters them through Ghostscript before feeding them to the physical printer using the native Windows GDI driver. I did need to change some of the steps compared to the guide above, so I’ll provide a short guide here for others who may be looking to get their Winprinter working with Linux.

This is only a rough guide meant to give an idea of the steps required. You may need to figure out any appropriate intermediate steps and install the necessary software dependencies (e.g., samba).

Step 1: Find a networked Windows box and install the printer there
I used an instance of Windows XP running in VirtualBox on the print server itself. The networking is set to ‘Bridged’ to allow connection from others on the network.

Step 2: [Windows] Install Ghostscript, GSView and RedMon – in that order
All of the above can be found at: http://pages.cs.wisc.edu/~ghost/. I used GPL Ghostscript 9.02, GSview 5.0 and RedMon 1.7 on the Windows guest VM.

Step 3: [Windows] Configure GSprint for non-interactive printing
This is done by creating a configuration file (gsprint.cfg) in the same directory as the gsprint.exe executable. This should be in “$PATH_TO_GSVIEW”. I put the following in gsprint.cfg:

-noquery
-color
-printer
EPSON AL-C1750N

Note that each option must go on a separate line and “EPSON AL-C1750N” is the name of the printer as it appears in the Windows Control Panel. Again, note that the printer name is specified without quotes. The original guide also specifies the -ghostscript option but I found that it fails to work with that. It was best to let gsprint choose the correct Ghostscript binary automatically.

After creating the configuration file for gsprint, it is prudent to check that it functions as expected by running the following from a Windows command line:

> cd $PATH_TO_GSPRINT
> gsprint sample_ps_file.ps

The printer should now produce the sample PS file without any further input/intervention from the user.

Step 4: [Windows] Create dummy PostScript printer(s)
Use the “Add new printer” to create dummy PS printers. I created two of them — one for grayscale output and one for color. When creating the printers, choose “Local printer” and then “FILE:” as the port type. I chose the “Canon PS-IPU Color Laser Copier v52.3” as the printer model because it is a PostScript color laser printer that would allow both color and grayscale printing. The guide suggests something like the “Apple LaserWriter II NT” but that only produces grayscale output. I named the first printer “PSPrinter_BW” and the other “PSPrinter_Color”. The properties of the printer were set such that jobs sent to PSPrinter_BW are printed in grayscale while those sent to PSPrinter_Color are printed in color. Sharing is also turned on for both printers.

Step 5: [Windows] Set dummy printers to use RedMon
For each of the printers, go to “Printer properties” -> “Ports” -> “Add port”. Select “Redirected port” and click “New port”. Specify a name for the port, e.g., “RPT1:”. After adding the port, go to “Configure port” and fill out the necessary settings. For PSPrinter_Color, I have:

Redirect to program: $PATH_TO_GSPRINT.EXE
Arguments for program: -
Output: "Program handles output"
Run as user: [ ] (i.e., unchecked)

For PSPrinter_BW, I have:

Redirect to program: $PATH_TO_GSPRINT.EXE
Arguments for program: -mono -
Output: "Program handles output"
Run as user: [ ] (i.e., unchecked)

Click “OK” and close the printer properties dialog. Check that the port redirection works by printing something to PSPrinter_* and collecting the output from the physical printer.

Step 6: [Linux] Add share dummy printers to Linux
Using the printer administration module, add the shared PS printer(s) as “Windows Printer via SAMBA”. For the printer model/driver, I chose “Generic” -> “PostScript Printer”.

That’s it! It should now be possible to print to the physical printer from Linux by sending the job to the printer created in Step 6.

Update [18 July, 2012]: The EPSON AL-C1750N appears to work with the Linux drivers for the Xerox Phaser 6000. On 64bit Centos 6 it was also necessary to install the 32bit version of cups-libs. This was pointed out by Lathrop in the comments.

13 Comments :, , , , , , , , , more...

Printing multi-page duplex documents

by on Oct.18, 2009, under How To ..., Linux, Software

The psnup tool can be used to place multiple pages on each sheet of a document. E.g., the following command places two pages from the input file into each sheet of the output:

$ psnup -l -2 input.ps output.ps

While psnup is excellent for quick “N-up” conversion jobs, it doesn’t provide much control over the layout. The pstops utility on the other hand allows for fine grained scale, rotation and placement settings for each page that goes into a sheet of the output. The command syntax is a bit more complicated on account of the page specification strings that must now be provided. The following example shows a typical command needed to prepare a document for duplex printing with two pages on each side of a sheet:

$ pstops -pa4 \
  '4:0L@0.8(21cm,-1cm)+1L@0.8(21cm,12.55cm),2R@0.8(0,29.85cm)+3R@0.8(0,16.25cm)' \
  input.ps output.ps

The command is best understood by referring to the relevant section from the manpage:

       Pstops rearranges pages from a  PostScript  document,  creating  a  new
       PostScript  file.   The  input  PostScript file should follow the Adobe
       Document Structuring Conventions.  Pstops can  be  used  to  perform  a
       large  number  of  arbitrary  re-arrangements  of  Documents, including
       arranging for printing 2-up, 4-up, booklets, reversing, selecting front
       or back sides of documents, scaling, etc.

       pagespecs follow the syntax:

              pagespecs   = [modulo:]specs

              specs       = spec[+specs][,specs]

              spec        = [-]pageno[L][R][U][@scale][(xoff,yoff)]

       modulo is the number of pages in each block. The value of modulo should
       be greater than 0; the default value is 1.  specs are the page specifi-
       cations  for  the  pages in each block. The value of the pageno in each
       spec should be between 0 (for the first page in the block) and modulo-1
       (for  the  last page in each block) inclusive.  The optional dimensions
       xoff and yoff shift the page by the specified amount.   xoff  and  yoff
       are  in  PostScript’s points, but may be followed by the units cm or in
       to convert to centimetres or inches, or the flag w or h to specify as a
       multiple  of  the width or height.  The optional parameters L, R, and U
       rotate the page left, right, or upside-down.  The optional scale param-
       eter  scales the page by the fraction specified.  If the optional minus
       sign is specified, the page is relative to the  end  of  the  document,
       instead of the start.

       If  page  specs  are  separated  by + the pages will be merged into one
       page; if they are separated by  they will be  on  separate  pages.   If
       there  is only one page specification, with pageno zero, the pageno may
       be omitted.

       The shift, rotation, and scaling are performed in that order regardless
       of which order they appear on the command line.
Leave a Comment :, , , , more...