Printing with CUPS to a Samsung ML-1740

Author

This page at linuxprinting.org:

has some information about using the Samsung ML-1740 with Cups, including this ppd file: Samung1740PPD. Getting it to work was quite an adventure.

Be Warned

The linux server I did this on has Slackware 10.2 installed on it. Some of the exact details of the commands are slackware specific, like the existance of the script /etc/rc.d/rc.cups. Different distributions would place this file differently. I'm leaving it up to the reader to figure those sorts of details out.

Security Settings

CUPS has an elaborate security model controlled through the configuration file at:

/etc/cups/cups.conf

Placing this stanza somewhere in the file:

<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
</Location>

Will tell the cups daemon to allow all operations (admin, printing, ...) to work if they originate from the localhost, but deny all other hosts the right to do anything.

Further, placing this stanza:

<location /printers>
Allow from ALL
</location>

after the above one, will loosen that policy to allow other hosts to print.

You want to add both of these stanzas to your /etc/cups/cups.conf

Linux Client -> Linux Server Printing with CUPS

This procedure won't work for a windows client to a linux server unless you modify the Samsung ppd file, which I detail in a later section. Here is a command sequence to setup the linux server:

# copy the ppd file to where cupsd will find it
cp Samsung-ML-1740-gdi.ppd /usr/share/cups/model/

# enable the cups system by marking its boot script as executable
cd /etc/rc.d/
chmod a+rx ./rc.cups

# restart cupsd using its boot script so it will know about the ppd file you just placed
./rc.cups restart

# add a printer named "samsung", using the new ppd and the first usb printer port.
lpadmin -p samsung -v usb:/dev/usb/lp0 -D "abc" -L "def" -m Samsung-ML-1740-gdi.ppd -E

Here is how I would test it from the command line:

# get a short text file by listing the root directory
ls / > dir.txt

# make a postscript file out of it
enscript -p print.ps -f Courier8 -M Letter dir.txt print.ps

# submit the postscript file to CUPS for printing
lpr -Psamsung print.ps

Windows Client -> Linux Server Printing with CUPS

The above server configuration establishes the CUPS samsung printer we just configured as an IPP printer at the following URL:

http://localhost:631/printers/samsung

Here is how I would describe the point-and-click obstacle course you have to go through to setup a windows client with a "printer" it can use to submit print jobs to the samsung. We assume the linux server has IP 10.0.3.1:

start->control_panel->printers->add_printer
   select the "URL" radio button
   set URL to "http://10.0.3.1:631/printers/samsung"
   click next
      select a fairly generic postscript driver, like the HP Color PS

Fixing the Samsung PPD so windows can print through it

The Samung1740PPD I downloaded from www.linuxprinting.org won't work as-is. For some reason, it doesn't like windows originated postscript, even though the ghostscript utilities have no problem with it. Rather than edit the original ppd file, I am going to create a second one called Samsung-ML-1740-gdi-test.ppd and copy it to /usr/share/cups/model. So where in a ppd file is the filter command that translates beween the incoming postscript and the native printer language? The original line looks like this:

*cupsFilter:    "application/vnd.cups-postscript 0 foomatic-rip"

The program foomatic-rip actually lives here

/usr/bin/foomatic-rip

although most of the filter programs that come with cups live here:

/usr/lib/cups/filter

such as imagetoraster, rastertohp, rastertoepson, and several others. We simply need to replace "foomatic-rip" with our script, which I will call ps2samsung:

*cupsFilter:    "application/vnd.cups-postscript 0 /usr/local/bin/ps2samsung"

here is ps2samsung

#!/bin/bash
gs -sDEVICE=samsunggdi -r600x600 -sPAPERSIZE=letter -dQUIET -dNOPAUSE -dBATCH -
dNOPROMPT -sOutputFile=- -dBATCH -

I also modified another setting in the Samung1740PPD from this:

*NickName:      "Samsung ML-1740 Foomatic/gdi"

to this:

*NickName:      "Samsung ML-1740 Foomatic/gdi test"

so that when adding printers through the http://localhost:631 CUPS interface on the linux server I see a list of choices that looks like this:

   Samsung ML-1740 Foomatic/gdi
   Samsung ML-1740 Foomatic/gdi test

instead of like this:

   Samsung ML-1740 Foomatic/gdi
   Samsung ML-1740 Foomatic/gdi

Assuming we called our new version of the ppd file Samsung-ML-1740-gdi-test.ppd, we create a new printer using it on the linux server like this:

cp Samsung-ML-1740-gdi-test.ppd /usr/share/cups/model
cd /etc/rc.d
./rc.cups restart
lpadmin -p samsung-test -v usb:/dev/usb/lp0 -D "abc" -L "def" -m Samsung-ML-1740-gdi-test.ppd -E

We add a windows "printer" to the client like this:

start->control_panel->printers->add_printer
   select the "URL" radio button
   set URL to "http://10.0.3.1:631/printers/samsung-test"
   click next
      select a fairly generic postscript driver, like the HP Color PS

And at this point we should be able to print from the windows client to the linux server through CUPS to a Samsung ML-1740 connected on the first USB printer port.

Notes

Here is the output in /var/log/cups/error from a successful print using my modified samsung ppd:

D [31/Oct/2006:16:41:38 -0500] AcceptClient: 5 from localhost:631.
D [31/Oct/2006:16:41:38 -0500] ReadClient: 5 POST / HTTP/1.1
D [31/Oct/2006:16:41:38 -0500] ProcessIPPRequest: 5 status_code=1
D [31/Oct/2006:16:41:38 -0500] ReadClient: 5 POST / HTTP/1.1
D [31/Oct/2006:16:41:38 -0500] ProcessIPPRequest: 5 status_code=1
D [31/Oct/2006:16:41:38 -0500] ReadClient: 5 POST / HTTP/1.1
D [31/Oct/2006:16:41:38 -0500] ProcessIPPRequest: 5 status_code=0
D [31/Oct/2006:16:41:39 -0500] AcceptClient: 7 from localhost:631.
D [31/Oct/2006:16:41:39 -0500] CloseClient: 5
D [31/Oct/2006:16:41:39 -0500] ReadClient: 7 POST /printers/samsung-test HTTP/1.1
D [31/Oct/2006:16:41:39 -0500] print_job: auto-typing file...
D [31/Oct/2006:16:41:39 -0500] print_job: request file type is application/postscript.
D [31/Oct/2006:16:41:39 -0500] check_quotas: requesting-user-name = 'chris'
D [31/Oct/2006:16:41:39 -0500] print_job: requesting-user-name = 'chris'
I [31/Oct/2006:16:41:39 -0500] Adding start banner page "none" to job 46.
I [31/Oct/2006:16:41:39 -0500] Adding end banner page "none" to job 46.
I [31/Oct/2006:16:41:39 -0500] Job 46 queued on 'samsung-test' by 'chris'.
D [31/Oct/2006:16:41:39 -0500] Job 46 hold_until = 0
D [31/Oct/2006:16:41:39 -0500] StartJob(46, 0x8105d00)
D [31/Oct/2006:16:41:39 -0500] StartJob() id = 46, file = 0/1
D [31/Oct/2006:16:41:39 -0500] job-sheets=none,none
D [31/Oct/2006:16:41:39 -0500] banner_page = 0
D [31/Oct/2006:16:41:39 -0500] StartJob: argv = "samsung-test","46","chris","print.ps","1","","/var/spool/cups/d00046-001"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[0]="PATH=/usr/lib/cups/filter:/bin:/usr/bin"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[1]="SOFTWARE=CUPS/1.1"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[2]="USER=root"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[3]="CHARSET=iso-8859-1"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[4]="LANG=en_US"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[5]="PPD=/etc/cups/ppd/samsung-test.ppd"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[6]="CUPS_SERVERROOT=/etc/cups"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[7]="RIP_MAX_CACHE=8m"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[8]="TMPDIR=/var/spool/cups/tmp"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[9]="CONTENT_TYPE=application/postscript"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[10]="DEVICE_URI=usb://Samsung/ML-1740"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[11]="PRINTER=samsung-test"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[12]="CUPS_DATADIR=/usr/share/cups"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[13]="CUPS_FONTPATH=/usr/share/cups/fonts"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[14]="CUPS_SERVER=localhost"
D [31/Oct/2006:16:41:39 -0500] StartJob: envp[15]="IPP_PORT=631"
D [31/Oct/2006:16:41:39 -0500] StartJob: statusfds = [ 5 8 ]
D [31/Oct/2006:16:41:39 -0500] StartJob: filterfds[1] = [ 9 -1 ]
D [31/Oct/2006:16:41:39 -0500] StartJob: filter = "/usr/lib/cups/filter/pstops"
D [31/Oct/2006:16:41:39 -0500] StartJob: filterfds[0] = [ 10 11 ]
D [31/Oct/2006:16:41:39 -0500] start_process("/usr/lib/cups/filter/pstops", 0xbffefb90, 0xbffeef00, 9, 11, 8)
I [31/Oct/2006:16:41:39 -0500] Started filter /usr/lib/cups/filter/pstops (PID 7912) for job 46.
D [31/Oct/2006:16:41:39 -0500] StartJob: filter = "/usr/local/bin/ps2samsung"
D [31/Oct/2006:16:41:39 -0500] StartJob: filterfds[1] = [ 9 12 ]
D [31/Oct/2006:16:41:39 -0500] start_process("/usr/local/bin/ps2samsung", 0xbffefb90, 0xbffeef00, 10, 12, 8)
I [31/Oct/2006:16:41:39 -0500] Started filter /usr/local/bin/ps2samsung (PID 7913) for job 46.
D [31/Oct/2006:16:41:39 -0500] StartJob: backend = "/usr/lib/cups/backend/usb"
D [31/Oct/2006:16:41:39 -0500] StartJob: filterfds[0] = [ -1 10 ]
D [31/Oct/2006:16:41:39 -0500] start_process("/usr/lib/cups/backend/usb", 0xbffefb90, 0xbffeef00, 9, 10, 8)
I [31/Oct/2006:16:41:39 -0500] Started backend /usr/lib/cups/backend/usb (PID 7914) for job 46.
D [31/Oct/2006:16:41:39 -0500] ProcessIPPRequest: 7 status_code=0
D [31/Oct/2006:16:41:39 -0500] CloseClient: 7
D [31/Oct/2006:16:41:39 -0500] [Job 46] Page = 595x842; 0,0 to 595,842
D [31/Oct/2006:16:41:39 -0500] [Job 46] slowcollate=0, slowduplex=0, sloworder=0
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%BoundingBox: 38 24 574 768
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%Title: Enscript Output
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%For: 
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%Creator: GNU enscript 1.6.3
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%CreationDate: Tue Oct 31 16:41:00 2006
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%Orientation: Portrait
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%Pages: (atend)
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%DocumentMedia: Letter 612 792 0 () ()
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%DocumentNeededResources: (atend)
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%EndComments
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%BeginProlog
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%BeginResource: procset Enscript-Prolog 1.6 3
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%EndResource
D [31/Oct/2006:16:41:39 -0500] [Job 46] 0 %%BeginResource: procset Enscript-Encoding-88591 1.6 3
D [31/Oct/2006:16:41:39 -0500] [Job 46] Printer using device file "/dev/usb/lp0"...
D [31/Oct/2006:16:41:39 -0500] [Job 46] LPGETSTATUS returned a port status of 18...
D [31/Oct/2006:16:41:42 -0500] AcceptClient: 7 from localhost:631.
D [31/Oct/2006:16:41:42 -0500] AcceptClient: 8 from localhost:631.
D [31/Oct/2006:16:41:42 -0500] ReadClient: 8 POST / HTTP/1.1
D [31/Oct/2006:16:41:42 -0500] ProcessIPPRequest: 8 status_code=1
D [31/Oct/2006:16:41:42 -0500] ReadClient: 8 POST / HTTP/1.1
D [31/Oct/2006:16:41:42 -0500] ProcessIPPRequest: 8 status_code=1
D [31/Oct/2006:16:41:42 -0500] ReadClient: 8 POST / HTTP/1.1
D [31/Oct/2006:16:41:42 -0500] ProcessIPPRequest: 8 status_code=0
D [31/Oct/2006:16:41:42 -0500] ReadClient: 7 POST / HTTP/1.1
D [31/Oct/2006:16:41:42 -0500] ProcessIPPRequest: 7 status_code=0
D [31/Oct/2006:16:41:42 -0500] CloseClient: 8
D [31/Oct/2006:16:41:42 -0500] ReadClient: 7 POST / HTTP/1.1
D [31/Oct/2006:16:41:42 -0500] ProcessIPPRequest: 7 status_code=0
D [31/Oct/2006:16:41:42 -0500] CloseClient: 7
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%EndResource
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%EndProlog
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%BeginSetup
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%IncludeResource: font Courier-Bold
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%IncludeResource: font Courier
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%BeginResource: procset Enscript-Header-simple 1.6 3
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%EndResource
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%EndSetup
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%Page: (1) 1
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%Page: (1) 1
D [31/Oct/2006:16:41:44 -0500] [Job 46] pw = 595.0, pl = 842.0
D [31/Oct/2006:16:41:44 -0500] [Job 46] PageLeft = 0.0, PageRight = 595.0
D [31/Oct/2006:16:41:44 -0500] [Job 46] PageTop = 842.0, PageBottom = 0.0
D [31/Oct/2006:16:41:44 -0500] [Job 46] PageWidth = 595.0, PageLength = 842.0
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%BeginPageSetup
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%EndPageSetup
D [31/Oct/2006:16:41:44 -0500] [Job 46] 0 %%Trailer
D [31/Oct/2006:16:41:44 -0500] [Job 46] Saw Trailer!
D [31/Oct/2006:16:41:44 -0500] [Job 46] Saw EOF!
D [31/Oct/2006:16:41:44 -0500] UpdateJob: job 46, file 0 is complete.
D [31/Oct/2006:16:41:44 -0500] CancelJob: id = 46
D [31/Oct/2006:16:41:44 -0500] StopJob: id = 46, force = 0
D [31/Oct/2006:16:41:44 -0500] StopJob: printer state is 3
D [31/Oct/2006:16:41:50 -0500] AcceptClient: 5 from localhost:631.
D [31/Oct/2006:16:41:50 -0500] AcceptClient: 7 from localhost:631.
D [31/Oct/2006:16:41:50 -0500] ReadClient: 7 POST / HTTP/1.1
D [31/Oct/2006:16:41:50 -0500] ProcessIPPRequest: 7 status_code=1
D [31/Oct/2006:16:41:50 -0500] ReadClient: 7 POST / HTTP/1.1
D [31/Oct/2006:16:41:50 -0500] ProcessIPPRequest: 7 status_code=1
D [31/Oct/2006:16:41:50 -0500] ReadClient: 7 POST / HTTP/1.1
D [31/Oct/2006:16:41:50 -0500] ProcessIPPRequest: 7 status_code=0
D [31/Oct/2006:16:41:50 -0500] ReadClient: 5 POST / HTTP/1.1
D [31/Oct/2006:16:41:50 -0500] ProcessIPPRequest: 5 status_code=0
D [31/Oct/2006:16:41:50 -0500] CloseClient: 7
D [31/Oct/2006:16:41:50 -0500] ReadClient: 5 POST / HTTP/1.1
D [31/Oct/2006:16:41:50 -0500] ProcessIPPRequest: 5 status_code=0
D [31/Oct/2006:16:41:50 -0500] CloseClient: 5

hopeless_linux: Cups (last modified 2007-07-01 16:01:00)