Xpra: Ticket #598: support for printing via a cups backend script

We should be able to place our own script in /usr/lib/cups/backend/ and have it forward the data to print to the client using xpra control. (see also #494)



Mon, 14 Jul 2014 17:10:42 GMT - Antoine Martin: attachment set

work in progress patch


Thu, 17 Jul 2014 20:39:18 GMT - Antoine Martin: attachment set

updated patch


Tue, 19 Aug 2014 02:59:40 GMT - Antoine Martin: owner, priority, status, milestone changed

Scheduling for this release.


Thu, 05 Feb 2015 11:31:45 GMT - Antoine Martin: attachment set

updated patch with rpm packaging


Fri, 06 Feb 2015 05:20:48 GMT - Antoine Martin:

Some useful links:

On Fedora, the PPD file we can use for PDF is found in /usr/share/ppd/cupsfilters/Generic-PDF_Printer-PDF.ppd and is part of the cups-filters package.

On Fedora, to be able to use lpadmin, you need to be a member of the sys group:

sudo gpasswd -a antoine sys

Each distribution does its own thing (oh great..), see https://bugs.launchpad.net/hplip/+bug/674570/comments/4:

Adding SystemGroup lp to /etc/cups/cupsd.conf and adding yourself to the lp group does nothing. No idea why. You have to use sys..

Running lpinfo -v can take a very long time.

To add a virtual printer which uses the xpraforwarder backend we drop in /usr/lib/cups/backend/, do:

lpadmin -p xpra -E -v xpraforwarder:/tmp/

And to remove it:

lpadmin -x xpra

check its status:

lpstat -p xpra

To check the state of its queue:

lpq -P xpra

Maybe we should allow the client to specify which PPD file to use? And maybe even upload it to the server? Then we can add the printer using this PPD file? Or pass the PPD file to ghostscript when we generate the PDF?


Mon, 09 Feb 2015 16:43:13 GMT - Antoine Martin:

New TODO / work in progress items:


Tue, 10 Feb 2015 11:33:54 GMT - Antoine Martin:

New problems:


Wed, 11 Feb 2015 08:23:02 GMT - Antoine Martin: attachment set

almost working patch


Thu, 12 Feb 2015 05:33:45 GMT - Antoine Martin: attachment set

hacked patch for testing


Thu, 12 Feb 2015 10:03:10 GMT - Antoine Martin: attachment set

much better implementation using pipes and straight postscript


Mon, 16 Feb 2015 09:34:50 GMT - Antoine Martin:

Merged most of it in r8667, see long commit message.

Still TODO:

Note: I have seen lockups sometimes so this feature is currently disabled by default. More work is needed anyway. (the backtrace seemed to be in the clipboard code, hence #812, but had some nvidia stuff in it... which could also play a role here)


Wed, 18 Feb 2015 09:59:44 GMT - Antoine Martin:

New TODO:


Mon, 23 Feb 2015 16:26:29 GMT - Antoine Martin:


Wed, 25 Feb 2015 13:09:34 GMT - Antoine Martin: owner, status changed

I think this is ready for an initial round of testing and feedback. Remember to enable printing, either in the config file or on the command line, for both the client and server. And disable selinux with a setenforce 0 as root.


Fri, 27 Feb 2015 11:37:28 GMT - Antoine Martin: attachment set

simpler solution for selinux and cups


Fri, 27 Feb 2015 15:12:59 GMT - Antoine Martin:

Rather than writing a full policy (#815), the patch above creates a very minimal policy which allows us to transition from the cups backend context to a xpra_cups domain, which is allowed to connect to the server.

Except it doesn't work, or works by accident. Trying to define the context properly, I get a stream of:

libsepol.context_from_record: invalid security context: "system_u:system_r:xpra_cups_t:s0-s0:c0.c1023"
libsepol.context_from_record: could not create context structure
libsepol.context_from_string: could not create context structure
libsepol.sepol_context_to_sid: could not convert system_u:system_r:xpra_cups_t:s0-s0:c0.c1023 to sid

And as usual with selinux, getting meaningful information out of those errors is next to impossible. A day wasted, solution: just disable selinux for now.


Fri, 27 Feb 2015 23:28:54 GMT - J. Max Mena: owner changed

Tested an r8709 Win8.1 client against an r8705 Fedora 20 server:

Running with setenforce 0(selinux disabled) and --printing=yes on both computers, the Windows client receives the print command but then I get the following error output in the CMD window:

   Traceback (most recent call last):
  File "xpra\platform\win32\gui.pyc", line 249, in remove_window_hooks
  File "xpra\platform\win32\window_hooks.pyc", line 85, in cleanup
AttributeError: 'Win32Hooks' object has no attribute 'old_win32_proc'
2015-02-27 13:20:59,697 failed to set group leader: 'module' object has no attri
bute 'SHGetPropertyStoreForWindow'
2015-02-27 13:21:04,198 remove_window_hooks(%s)
Traceback (most recent call last):
  File "xpra\platform\win32\gui.pyc", line 249, in remove_window_hooks
  File "xpra\platform\win32\window_hooks.pyc", line 85, in cleanup
AttributeError: 'Win32Hooks' object has no attribute 'old_win32_proc'

As far as I can tell it successfully adds the virtual printer(it shows up in the print prompt!) and then forwards it to Windows, but the Windows client is failing to print.


Sat, 28 Feb 2015 01:57:55 GMT - Antoine Martin:

SHGetPropertyStoreForWindow errors have now been reported in tickets #775, #756 and here... can we please get to the bottom of those where it belongs: #799.


the Windows client receives the print command but then I get...


This error is fixed in r8713 but should not have been able to affect printing.

Why is it failing to print? Is there anything in the print queue? In the windows event log? Please also include the -d printing log for both server and client.


Sat, 28 Feb 2015 05:21:08 GMT - Antoine Martin: owner, status changed

OK, found some problems with win32:


Sat, 28 Feb 2015 06:20:07 GMT - Antoine Martin:

I've tried using this code sample, but nothing happens, no errors... (it briefly shows up in the print queue then disappears!)

        h=win32print.OpenPrinter(printer)
        win32print.StartDocPrinter(h, 1, (title, None, "raw"))
        win32print.WritePrinter(h, file(f).read())
        win32print.EndDocPrinter(h)
        win32print.ClosePrinter(h)

Now, this works, using gsprint:

def print_files(printer, filenames, title, options):
    log("print_files%s", (printer, filenames, title, options))
    assert gsprint_dir, "cannot print files without gsprint!"
    for f in filenames:
        log("win32api.ShellExecute%s", (0, 'open', 'gsprint.exe', '-printer "%s" %s' % (printer, f), '.', 0))
        win32api.ShellExecute(0, 'open', 'gsprint.exe', '-printer "%s" "%s"' % (printer, f), '.', 0)

But somehow the ps files I try to open are showing empty!? (but they do print on unix!)


Sat, 28 Feb 2015 16:21:36 GMT - Antoine Martin:

After further testing, both the gsprint option and the original ShellExecute "printto" options work, as long as we feed it the "right kind" of postscript document. And apparently the one that comes out of cups isn't right. (works for unix printing..) Maybe we do need different ppd files for each client.. (PITA). If needed, bundling gsprint it is not a huge problem (it is GPL). Then we can just add the gsview directory to sys.path. (tested OK).

This is all made so much harder by cups on Fedora 21 getting into a spin, not seeing the printer, not giving me the option to re-add it. So now I can test win32 via virtualbox, but not native.


Sun, 01 Mar 2015 06:44:20 GMT - Antoine Martin: attachment set

hacks to the win32 print code to try to figure out how to make it work..


Sun, 01 Mar 2015 06:48:43 GMT - Antoine Martin:

Some fixes and improvements in r8725 and r8726. With the printing tweaks patch above, it is much easier to test various implementations of the OS printing request, just by changing the GS env var. (and it also saves the file in C:\toprint.ps} which is easier to check against)

gsprint still crashes, both with ShellExecute and with subprocess.Popen, but the exact same command works fine when I run it from the command shell!? (and the printer output looks ok)

gsprint.exe -printer 'MyPrinterName' C:\toprint.ps

Sun, 01 Mar 2015 06:53:51 GMT - Antoine Martin:

Some useful links I found along the way - which could still be useful:


Mon, 02 Mar 2015 05:42:33 GMT - Antoine Martin:

More improvements in r8732 + r8733.

I swear I had it working reliably, printed stuff using gimp, gedit and abiword without problems. But now when I look at the resulting postscript file now, it doesn't open! Blank on win32 with gsview, crashes evince on linux. WTF.

New ideas and links:


Mon, 02 Mar 2015 08:00:57 GMT - Antoine Martin:

Created a wiki page: wiki/Printing


Mon, 02 Mar 2015 08:56:57 GMT - Antoine Martin: attachment set

example of a file we get from cups using the Cups-PDF.ppd


Mon, 02 Mar 2015 08:59:46 GMT - Antoine Martin:

As can be seen in the file above, the problem seems to occur somewhere in cups (tested on Fedora 20 and Fedora 21 with the cups pdf filter). The file contains:

systemdict begin
$error begin
newerror
{(%%[ Error handled by opdfread.ps : )print errorname//ebuf cvs print(; OffendingCommand: )
print/command load//ebuf cvs print( ]%%)= flush
/newerror false store vmstatus pop pop 0 ne
{grestoreall
}if

And something like it gets printed client side...

But I am certain this was working at some point! Options:


Tue, 03 Mar 2015 05:47:22 GMT - Antoine Martin:

Some more minor tweaks: r8740 + r8742.

Good news: if I capture the file from the spooler, pass it to MS Windows, gsprint can deal with it. The bad news: systemd's journal is being #### and swallowing my log messages now (it wasn't earlier). Which is the easiest way of capturing stuff in the backend.


Tue, 03 Mar 2015 10:24:55 GMT - Antoine Martin: owner, status changed

I don't understand how it ever worked on win32 before r8743, but I swear that it did! Python on win32 was screwing with the newline characters of the binary data... despite us opening the file in binary mode!? (I have verified that this was not the cause of the problems trying to use the win32print API, so we still cannot use that) In the process of debugging this problem, the logging has been improved and we now include a SHA1 checksum of the file data. (which didn't really help because the data was fine... it was python's IO write that corrupted it!)

Ready for testing, again. Please remember to use -d printing,file in bug reports.

Note: you will need to install gsview 5.0 in its default location on the build machine so it gets included in the installer. (C:\Program Files\Ghostgum\gsview)

PS: I was having problems with Linux clients now! (I suspect cups is a bit hosed, and I haven't tried reverting to the code that did work to confirm it - win32 being harder to support, we can fix posix clients later - shouldn't be as hard)


Recap for myself of the tasks that would need to be completed for this release (others can wait):


Fri, 06 Mar 2015 23:59:50 GMT - J. Max Mena:

Retested with r8743 Win8.1 client against an r8743 Fedora 20 server:

lpadmin: Unable to open PPD file "/usr/share/cups/model/CUPS-PDF.ppd" - No such file or directory
lpadmin: Unable to open PPD file "/usr/share/cups/model/CUPS-PDF.ppd" - No such file or directory

And for more prints:

Client:

2015-03-06 15:57:13,563 server: Linux Fedora 20 Heisenbug, Xpra version 0.15.0 (
r8743)
2015-03-06 15:57:13,563 found printer: 8388608, Printer Behind Xander,HP LaserJe
t Pro CM1415 MFP PCL6 Class Driver,, Printer Behind Xander,
2015-03-06 15:57:13,579 skipped printer: 8388608, Microsoft XPS Document Writer,
Microsoft XPS Document Writer v4,, Microsoft XPS Document Writer,
2015-03-06 15:57:13,579 found printer: 8388608, Fax,Microsoft Shared Fax Driver,
, Fax,
2015-03-06 15:57:13,579 win32.get_printers()={'Fax': {'printer-info': 'Fax,Micro
soft Shared Fax Driver'}, 'Printer Behind Xander': {'printer-info': 'Printer Beh
ind Xander,HP LaserJet Pro CM1415 MFP PCL6 Class Driver'}}
2015-03-06 15:57:13,579 process_query_printers(['query-printers']) found printer
s={'Fax': {'printer-info': 'Fax,Microsoft Shared Fax Driver'}, 'Printer Behind X
ander': {'printer-info': 'Printer Behind Xander,HP LaserJet Pro CM1415 MFP PCL6
Class Driver'}}
2015-03-06 15:57:13,579 process_query_printers(['query-printers']) exported prin
ters=Fax, Printer Behind Xander
2015-03-06 15:57:13,625 Attached to tcp:10.0.32.52:2200 (press Control-C to deta
ch)

And server:

2015-03-06 15:56:55,797 set_printers({'Fax': {'printer-info': 'Fax,Microsoft Shared Fax Driver'}, 'Printer Behind Xander': {'printer-info': 'Printer Behind Xander,HP LaserJet Pro CM1415 MFP PCL6 Class Driver'}})
2015-03-06 15:56:55,798 add_printer(Fax, {'printer-info': 'Fax,Microsoft Shared Fax Driver'})
2015-03-06 15:56:55,798 pycups_printing adding printer: ['-p', 'Fax', '-E', '-v', 'xpraforwarder:/tmp?remote-device-uri=None&source=da39a3ee5e6b4b0d3255bfef95601890afd80709&socket-dir=%2Fhome%2Fjimador%2F.xpra&display=%3A13&remote-printer=Fax', '-D', 'Fax,Microsoft Shared Fax Driver', '-L', 'on Max-Win81-MBP (via xpra)', '-o', 'printer-is-shared=false', '-u', 'allow:jimador', '-P', '/usr/share/cups/model/CUPS-PDF.ppd']
2015-03-06 15:56:55,805 add_printer(Printer Behind Xander, {'printer-info': 'Printer Behind Xander,HP LaserJet Pro CM1415 MFP PCL6 Class Driver'})
2015-03-06 15:56:55,806 pycups_printing adding printer: ['-p', 'Printer-Behind-Xander', '-E', '-v', 'xpraforwarder:/tmp?remote-device-uri=None&source=da39a3ee5e6b4b0d3255bfef95601890afd80709&socket-dir=%2Fhome%2Fjimador%2F.xpra&display=%3A13&remote-printer=Printer+Behind+Xander', '-D', 'Printer Behind Xander,HP LaserJet Pro CM1415 MFP PCL6 Class Driver', '-L', 'on Max-Win81-MBP (via xpra)', '-o', 'printer-is-shared=false', '-u', 'allow:jimador', '-P', '/usr/share/cups/model/CUPS-PDF.ppd']
lpadmin: Unable to open PPD file "/usr/share/cups/model/CUPS-PDF.ppd" - No such file or directory
lpadmin: Unable to open PPD file "/usr/share/cups/model/CUPS-PDF.ppd" - No such file or directory

Sun, 08 Mar 2015 06:47:32 GMT - Antoine Martin:

lpadmin: Unable to open PPD file "/usr/share/cups/model/CUPS-PDF.ppd" - No such file or directory

You need to install cups-pdf.

More generally speaking, you can figure out which package provides a file using either:


Sun, 08 Mar 2015 11:32:03 GMT - Antoine Martin:

Some updates:

Note: when testing, do not mix earlier beta builds with newer ones. Printing will not work as r8750 changes how we sync printers.


Mon, 09 Mar 2015 18:39:21 GMT - J. Max Mena:

Retested with an r8769 Win8.1 client against an r8769 Fedora 20 server:

I get the following client side prints when attempting to print:

2015-03-09 11:15:59,131 win32.get_printers()={'Fax': {'printer-info': 'Fax,Micro
soft Shared Fax Driver'}, 'Printer Behind Xander': {'printer-info': 'Printer Beh
ind Xander,HP LaserJet Pro CM1415 MFP PCL6 Class Driver'}}
2015-03-09 11:15:59,131 do_send_printers() found printers={'Fax': {'printer-info
': 'Fax,Microsoft Shared Fax Driver'}, 'Printer Behind Xander': {'printer-info':
 'Printer Behind Xander,HP LaserJet Pro CM1415 MFP PCL6 Class Driver'}}
2015-03-09 11:15:59,131 do_send_printers() new printers: ['Fax', 'Printer Behind
 Xander']
2015-03-09 11:15:59,131 do_send_printers() printers=['Fax', 'Printer Behind Xand
er']
2015-03-09 11:15:59,131 do_send_printers() exported printers=Fax, Printer Behind
 Xander
2015-03-09 11:16:11,885 received file: ['da39a3ee5e6b4b0d3255bfef95601890afd8070
9', 'application/pdf', True, True, 1272931, '1272931 bytes', {'title': '500px-As
tronautSloth.jpg (JPEG Image, 500\xc2\xa0\xc3\x97\xc2\xa0638 pixels)', 'sha1': '
2638a5ee43523e0d1f36ec6f38881579a312f7ff', 'options': {'PageSize': 'Letter', 'ti
me-at-processing': '1425924942', 'number-up': '1', 'job-uuid': 'urn:uuid:72a7695
b-6e9f-361b-7231-cd3ce17aec21', 'time-at-creation': '1425924942', 'Resolution':
'300dpi', 'job-originating-host-name': 'localhost'}, 'printer': 'Printer Behind
Xander', 'copies': '1'}]
2015-03-09 11:16:11,888 sha1 digest: 2638a5ee43523e0d1f36ec6f38881579a312f7ff -
expected: 2638a5ee43523e0d1f36ec6f38881579a312f7ff
2015-03-09 11:16:11,931 downloaded 1272931 bytes to application/pdf file C:\User
s\Max\Downloads\da39a3ee5e6b4b0d3255bfef95601890afd80709.pdf
2015-03-09 11:16:11,931 safe print options({'copies': '1', 'sha1': '2638a5ee4352
3e0d1f36ec6f38881579a312f7ff', 'options': {'PageSize': 'Letter', 'time-at-proces
sing': '1425924942', 'number-up': '1', 'job-uuid': 'urn:uuid:72a7695b-6e9f-361b-
7231-cd3ce17aec21', 'time-at-creation': '1425924942', 'Resolution': '300dpi', 'j
ob-originating-host-name': 'localhost'}, 'printer': 'Printer Behind Xander', 'ti
tle': '500px-AstronautSloth.jpg (JPEG Image, 500\xc2\xa0\xc3\x97\xc2\xa0638 pixe
ls)'}) = {'Resolution': '300dpi', 'PageSize': 'Letter'}
2015-03-09 11:16:11,933 win32.print_files('Printer Behind Xander', ['C:\\Users\\
Max\\Downloads\\da39a3ee5e6b4b0d3255bfef95601890afd80709.pdf'], '500px-Astronaut
Sloth.jpg (JPEG Image, 500\xc2\xa0\xc3\x97\xc2\xa0638 pixels)', {'Resolution': '
300dpi', 'PageSize': 'Letter'})
2015-03-09 11:16:11,934 print command: [u'C:\\Program Files (x86)\\Xpra\\gsview\
\gsprint.exe', '-printer', 'Printer Behind Xander', 'C:\\Users\\Max\\Downloads\\
da39a3ee5e6b4b0d3255bfef95601890afd80709.pdf']
2015-03-09 11:16:11,936 win32.print_files(..)=1 ([<subprocess.Popen object at 0x
075DF9D0>])
2015-03-09 11:16:11,936 printing C:\Users\Max\Downloads\da39a3ee5e6b4b0d3255bfef
95601890afd80709.pdf, job=1
2015-03-09 11:16:11,937 win32.printing_finished(1) processes: ['C:\\Users\\Max\\
Downloads\\da39a3ee5e6b4b0d3255bfef95601890afd80709.pdf']
2015-03-09 11:16:11,937 win32.printing_finished(1) still pending: ['C:\\Users\\M
ax\\Downloads\\da39a3ee5e6b4b0d3255bfef95601890afd80709.pdf']
2015-03-09 11:16:11,937 printing_finished(1)=False
2015-03-09 11:16:21,938 win32.printing_finished(1) processes: ['C:\\Users\\Max\\
Downloads\\da39a3ee5e6b4b0d3255bfef95601890afd80709.pdf']
2015-03-09 11:16:21,938 win32.printing_finished(1) still pending: []
2015-03-09 11:16:21,938 printing_finished(1)=True

It looks like it's getting the file correctly and then attempting to print but I don't get an error or anything. As far as the -d printing,file prints go it's seeing the file and printing, but the job never makes it to the printer(according to the Windows Control Panel)


In addition, here are the relevant server side prints(if needed):

2015-03-09 11:15:42,327 New connection received: SocketConnection(/home/jimador/.xpra/camarena.spikes.eng-13)
2015-03-09 11:15:42,513 Python/GObject/Print Linux client version 0.15.0 connected from 'camarena.spikes.eng' as 'root' ('root')
2015-03-09 11:15:42,521 process_print: ('da39a3ee5e6b4b0d3255bfef95601890afd80709', 'application/pdf', '1272931 bytes', 'da39a3ee5e6b4b0d3255bfef95601890afd80709', '500px-AstronautSloth.jpg (JPEG Image, 500\xc2\xa0\xc3\x97\xc2\xa0638 pixels)', 'Printer Behind Xander', '1', 'PageSize=Letter Resolution=300dpi number-up=1 job-uuid=urn:uuid:72a7695b-6e9f-361b-7231-cd3ce17aec21 job-originating-host-name=localhost time-at-creation=1425924942 time-at-processing=1425924942')
2015-03-09 11:15:42,521 process_print: got 1272931 bytes for file da39a3ee5e6b4b0d3255bfef95601890afd80709
2015-03-09 11:15:42,525 sha1 digest: 2638a5ee43523e0d1f36ec6f38881579a312f7ff
2015-03-09 11:15:42,525 parsed printer options: {'sha1': '2638a5ee43523e0d1f36ec6f38881579a312f7ff', 'printer': 'Printer Behind Xander', 'options': {'PageSize': 'Letter', 'time-at-processing': '1425924942', 'number-up': '1', 'job-uuid': 'urn:uuid:72a7695b-6e9f-361b-7231-cd3ce17aec21', 'time-at-creation': '1425924942', 'Resolution': '300dpi', 'job-originating-host-name': 'localhost'}, 'copies': '1', 'title': '500px-AstronautSloth.jpg (JPEG Image, 500\xc2\xa0\xc3\x97\xc2\xa0638 pixels)'}
2015-03-09 11:15:42,525 sending file for printing to ServerSource(Protocol(SocketConnection(('10.0.32.52', 2200) - ('10.0.11.196', 55067))))
2015-03-09 11:15:42,526 send_file('da39a3ee5e6b4b0d3255bfef95601890afd80709', 'application/pdf', '1272931 bytes', True, True, {'sha1': '2638a5ee43523e0d1f36ec6f38881579a312f7ff', 'printer': 'Printer Behind Xander', 'options': {'PageSize': 'Letter', 'time-at-processing': '1425924942', 'number-up': '1', 'job-uuid': 'urn:uuid:72a7695b-6e9f-361b-7231-cd3ce17aec21', 'time-at-creation': '1425924942', 'Resolution': '300dpi', 'job-originating-host-name': 'localhost'}, 'copies': '1', 'title': '500px-AstronautSloth.jpg (JPEG Image, 500\xc2\xa0\xc3\x97\xc2\xa0638 pixels)'})
2015-03-09 11:15:42,528 not sending to ServerSource(Protocol(SocketConnection(/home/jimador/.xpra/camarena.spikes.eng-13))) (wanted uuid=da39a3ee5e6b4b0d3255bfef95601890afd80709)
2015-03-09 11:15:42,528 client Protocol(SocketConnection(/home/jimador/.xpra/camarena.spikes.eng-13)) has requested disconnection: done (detaching)
2015-03-09 11:15:42,528 Disconnecting client Protocol(SocketConnection(/home/jimador/.xpra/camarena.spikes.eng-13)): client request
2015-03-09 11:15:42,529 xpra client disconnected.

Tue, 10 Mar 2015 00:50:01 GMT - Antoine Martin: owner changed

Can you please verify that gsprint works properly, by running it by hand:

C:\Program Files (x86)\Xpra\gsview\gsprint.exe -printer "Printer Behind Xander" "SOMEPDFFILEYOUCANFIND"

Tue, 10 Mar 2015 17:48:14 GMT - J. Max Mena: owner changed

I had to manually download and install ghostscript (couldn't find if you packaged it or not) and then point gsprint at it. It wanted to print(I saw the job show up for less than a second in the print queue), but failed with the following output:

C:\Program Files (x86)\Xpra\gsview>gsprint.exe -ghostscript "C:\Program Files (x
86)\gs\gs9.15\bin\gswin32c" -print "Printer Behind Xander" "C:\Users\Max\Desktop
\pdf-sample.pdf"
Copyright (C) 2003-2006, Ghostgum Software Pty Ltd.  All Rights Reserved.
2006-02-24 gsprint 1.9
Unknown switch -print - ignoring
GPL Ghostscript 9.15 (2014-09-22)
Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefinedfilename in (Printer Behind Xander)
Operand stack:
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval-
-   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   fa
lse   1   %stopped_push
Dictionary stack:
   --dict:1191/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.15: Unrecoverable error, exit code 1
C:\Program Files (x86)\Xpra\gsview>

Tue, 10 Mar 2015 18:52:06 GMT - J. Max Mena:

Upon further spelunking in Google, I found this webpage (http://pages.cs.wisc.edu/~ghost/gsview/gsprint.htm) that will actually list the commands and arguments. After editing my command to

gsprint.exe -ghostscript "C:\Program Files (x86)\gs\gs9.15\bin\gswin32c" -printer "Printer Behind Xander" "C:\pdf-sample.pdf"

It printed successfully.


Wed, 11 Mar 2015 09:05:52 GMT - Antoine Martin: owner changed

Well spotted. As of r8776, we bundle ghostscript and point to it. (it must be installed on the build machine)

So now the installer should work on machines without ghostscript already installed, and on 64-bit machines where the path is Program Files (86)(which I had not tested!)

I have uploaded a beta build with these changes.


Thu, 12 Mar 2015 19:05:11 GMT - J. Max Mena: owner changed

retested with the r8776 Win8.1 beta build against an r8769 Fedora 20 server(haven't gotten new builds yet):

Can post logs if interested


Passing back to you to decide how to proceed.

edit: upgraded the F20 server to r8776 trunk and retested: again, success.


Sat, 14 Mar 2015 05:23:04 GMT - Antoine Martin: owner, status changed

Thanks, there's a few more things I want to do, so I will own this ticket again for now. I had forgotten about the black and white thing (which I have seen), I'm pretty sure this is done in the PDF conversion step as I did print in colour before from a win32 client (using older version of the code). So I should be able to enable colour by doing the conversion step in our script rather than in the PPD layer.

As for the margins, I think we want to generate the PDF without any margins then use the printer defaults client side? (which will include its own margins) Rather than passing the margins to the server and then printing without margins. Whatever works best on all platforms... I guess I'll find out.


Tue, 17 Mar 2015 14:32:45 GMT - Antoine Martin:

Enabled printing by default in r8791 since the sound is now handled out-of-process (see #669)


Wed, 18 Mar 2015 01:40:17 GMT - Antoine Martin:


Fri, 20 Mar 2015 18:06:13 GMT - J. Max Mena:

Retested with r8802 Win8.1 client(from xpra.org/beta) against an r8795 Fedora 20 Server(in house build):


Sat, 21 Mar 2015 03:52:32 GMT - Antoine Martin:

Margins are much better


Margins should be unchanged! (exact same code)

Could you possibly print a page with just a rectangle right at the edge of the print area, so we can see where it ends up on the page? (what margins get added)


Sun, 22 Mar 2015 05:13:41 GMT - Antoine Martin: attachment set

osx printing: it is being difficult at doing very basic things, as usual


Sun, 22 Mar 2015 05:25:21 GMT - Antoine Martin:

OSX support (see ticket:533#comment:61 for build instructions)

With 10.6 onwards, it should work... the printer get detected and added, but it doesn't print because cups is being crap: osx printing: it is being difficult at doing very basic things, as usual Error: can't open `/private/var/spool/cups/d00001-001'. That file is created by cups itself when we ask it to print, why on earth can't it open its own file??

For packaging, we just add "cups" to the includes - that's done in r8812. That works OK, but we should replace the cups printer change notifications with some sort of polling as there is no dbus on OSX (or dig into the osx API - meh)


Mon, 23 Mar 2015 10:39:17 GMT - Antoine Martin: owner, status changed

In order to figure this out, r8818 adds a wrapper for the print tool. You can use it like so:

Please let me know if you can get any versions to work, and if not, what is show in the printer queue (as per comment:36)


Fri, 27 Mar 2015 00:00:02 GMT - alas:

Testing (locally) with a 0.15.0 r8848 osx client smo built for me, both of the above worked as expected (imagine that!). Just for fun, I'll paste in what I ran.

schadenfreude:~ Schadenfreude$ ./Desktop/xpra-catalog/xpra-smo8848/Xpra.app/Contents/Helpers/Print
* Xander_Dome                      : {'printer-is-shared': False, 'printer-info': u'Xander Dome', 'printer-state-message': u'', 'printer-type': 77598924, 'printer-make-and-model': u'HP LaserJet CM1415fnw-AirPrint', 'printer-state-reasons': [u'cups-ipp-conformance-failure-report', u'cups-ipp-missing-send-document'], 'printer-uri-supported': u'ipp://localhost:631/printers/Xander_Dome', 'printer-state': 3, 'printer-location': u'Xander_dome', 'device-uri': u'dnssd://HP%20LaserJet%20CM1415fnw%20(9C9B62)._ipp._tcp.local./?uuid=434e4a36-4435-4c52-4d51-a0b3cc9c9b62'}
schadenfreude:~ Schadenfreude$ ./Desktop//xpra-catalog/xpra-smo8848/Xpra.app/Contents/Helpers/Print "Xander_Dome" ~/Desktop/xpra-catalog/ScreenConfigurationList.pdf

Looks like you have parameters right. On to the next step?


Sat, 28 Mar 2015 00:49:37 GMT - alas:

Ok, tried to print a random page from the internet using firefox, same client and fedora 20 0.15.0 r8806 server.

The print dialog box, however, doesn't have the above mentioned printer, only a "Cups-PDF" printer.

Cups-PDF only printer showing with osx

Trying to print saves a pdf to the home directory of the fedora server account, but doesn't output anything server or client side with a -d printing flag, nor does anything land in the client-side printer queue.

Maybe the OSX wrapper just isn't in this server revision?


Sat, 28 Mar 2015 00:50:40 GMT - alas: attachment set

Cups-PDF only printer showing with osx


Sat, 28 Mar 2015 01:58:19 GMT - Antoine Martin:

@afarr: to debug this printing stuff, please include the -d printing log for both the server and client. Either the printer is not detected on the client (empty result when running the Printing helper without arguments as per comment:38), or something is going wrong on the server (selinux enforcing mode, no "sys" group membership, etc)


Sat, 28 Mar 2015 08:05:52 GMT - Antoine Martin:

r8853 fixes printing for *nix (all platforms that use pycups: Linux, OSX, etc), simply by using the correct file extension! (ghostprint on win32 ignores it and figures out it is a postscript file!) I haven't been able to test win32 or OSX today because virtualbox is not letting me pass-through USB devices, for whatever reason (and not the obvious ones: Why are my USB devices still grayed out in VirtualBox?) - unlikely to break things, but worth checking.


Mon, 30 Mar 2015 14:39:52 GMT - Antoine Martin:

Some improvements in r8871 (esp support for OSX printer changes), see commit message for details.


Mon, 30 Mar 2015 20:18:40 GMT - alas:

Ok, I'm officially a bit flummoxed.

OSX 0.15.0 r8872 client against a Fedora 20 0.15.0 r8872 server.

Server side I didn't forget setenforce 0, and running the gpasswd I got a Adding user jimador to group sys notification.

The local client is finding a printer:

schadenfreude:~ Schadenfreude$ ./Desktop/xpra-catalog/xpra-smo8872/Xpra.app/Contents/Helpers/Print
* Xander_Dome                      : {'printer-is-shared': False, 'printer-info': u'Xander Dome', 'printer-state-message': u'', 'printer-type': 77598924, 'printer-make-and-model': u'HP LaserJet CM1415fnw-AirPrint', 'printer-state-reasons': [u'cups-ipp-conformance-failure-report', u'cups-ipp-missing-send-document'], 'printer-uri-supported': u'ipp://localhost:631/printers/Xander_Dome', 'printer-state': 3, 'printer-location': u'Xander_dome', 'device-uri': u'dnssd://HP%20LaserJet%20CM1415fnw%20(9C9B62)._ipp._tcp.local./?uuid=434e4a36-4435-4c52-4d51-a0b3cc9c9b62'}

I start both client and server with --printing=yes and -d printing,file.

And, I get the exact same "Cups-PDF" printer option only, as above... and I get absolutely nothing in the way of client or server side output. When I print, a pdf lands in the home directory of the user server-side. I can only guess that the server isn't getting notification of the printer from the client, though the client can obviously see (and successfully print) via the client-side wrapper you put in. (Presumably the -d printing isn't outputting anything because everything is working as it expects, given that it can't detect the client-side available printer?)


Mon, 30 Mar 2015 20:20:59 GMT - alas:

got signal SIGINT, exiting
2015-03-30 13:19:01,116 server requested disconnect: client request
2015-03-30 13:19:01,116 cleanup_printing=<function cleanup_printing at 0x66b2df0>
2015-03-30 13:19:01,158 internal error: write connection TwoFileConnection() reset: [Errno 32] Broken pipe
/Users/Schadenfreude/Desktop/xpra-catalog/xpra-smo8872/Xpra.app/Contents/Resources/lib/python/xpra/gtk_common/gtk_util.py:250: Warning: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
2015-03-30 13:19:01,165 Connection lost
2015-03-30 13:19:01,165 cleanup_printing=<function cleanup_printing at 0x66b2df0>
2015-03-30 13:19:01,213 cleanup_printing=<function cleanup_printing at 0x66b2df0>
2015-03-30 13:19:01,661 cleanup_printing=<function cleanup_printing at 0x66b2df0>

Tue, 31 Mar 2015 08:42:09 GMT - Antoine Martin:

Hmm. There should be messages there if you have correctly enabled printing from the command line (which you should include as well). I will attach a sample log file, which shows the initialization of the printing subsystem - even if there are no printers to send, these messages should remain.

Does the same server allow printing when connecting with a client that is known to work with printing? (ie: MS Windows, or even Linux with latest builds).

You can verify that both the server and client have enabled printing with:

$ xpra info | egrep "client.printing|printing.enabled"
client.printing=True
printing.enabled=True

You could also try one of the builds I have just uploaded, to see if there are any differences.


Hmm, disconnecting the client, I just noticed an error that might be informative...


The only "error" there is the Broken pipe which is probably related to the sound process (we communicate with it using pipes). Nothing to worry about, you could confirm this by running without sound and see if it goes away.


Tue, 31 Mar 2015 08:42:46 GMT - Antoine Martin: attachment set

printing debug log from an osx 10.6.8 client with the latest trunk build


Tue, 31 Mar 2015 20:37:04 GMT - alas: owner changed

Launching your fedora 20 0.15.0 r8802 beta with [jimador@zapopan ~]$ dbus-launch xpra --no-daemon --bind-tcp=0.0.0.0:1201 --start-child=xterm --start-child=xterm --printing=yes start :23 -d printing,file, then connecting with smo's osx 0.15.0 r8872 client with schadenfreude:MacOS Schadenfreude$ ./xpra attach tcp:10.0.32.53:1201 --opengl=on --printing=yes -d printing,file I am getting the exact same behavior as I was with our 0.15.0 r8872 fedora 20 server.

Checking on the printing enabling, however, I see this, again - with both servers:

[jimador@zapopan ~]$ xpra info | egrep "client.printing|printing.enabled"
client.printing=True
printing.enabled=False

Once it was suggested that I install python-cups on the server, however, everything worked fine (aside from an issue with a printer that refused to recognize a wireless networked print job). Details details.

Handing this back, now that that not-bug has been sorted.


Wed, 01 Apr 2015 09:04:32 GMT - Antoine Martin: status changed; resolution set

I think what we have is good enough for the release. We can revisit and improve in new tickets as people find new issues with it.

PS: as of r8893, we grab the latest ghostscript version we find installed.


Thu, 02 Apr 2015 08:53:07 GMT - Antoine Martin:

Minor packaging tweaks in r8895 + r8896 + r8897: now that we can enable printing safely, add the correct RPM dependencies.

Note: cups-pdf is not available for centos, so it needs to be installed separately / by hand. (and centos 6 does not have pycups at all)


Fri, 08 May 2015 09:40:32 GMT - Antoine Martin:

r9284 (+backport in r9285) adds the packages as "suggestions" to the DEB packaging.

The page wiki/Printing has been updated.


Thu, 20 Aug 2015 08:21:38 GMT - Antoine Martin:

See also: #955, #494, #913.


Wed, 15 Nov 2017 11:29:14 GMT - Antoine Martin:

Follow up: #1344


Sat, 23 Jan 2021 05:00:28 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/598