Apache OpenOffice (AOO) Bugzilla – Issue 63169
Selecting printer in linux using Java/UNO not possible
Last modified: 2013-02-24 21:10:15 UTC
I try to select a printer using this code in Java: -----%<----- XPrintable xPrintable = (XPrintable) UnoRuntime.queryInterface(XPrintable.class, xDoc); PropertyValue[] printerDesc = new PropertyValue[1]; printerDesc[0] = new PropertyValue(); printerDesc[0].Name = "Name"; printerDesc[0].Value = "myPrinterName"; xPrintable.setPrinter(printerDesc); xPrintable.print(printOpts); -----%<----- This code works for Windows, Linux (only for printers that are created with spadmin). It does not work for CUPS native printers in Linux. The printout is always directed to the default printer. If I want to get the name of this printer, "Generic Printer" is returned. for questions or a sample application contact me: tuxmail-spam@bats.ch
sw->mba: I think XPrintable is in your area :-) ... On Windows and Solaris I can set a Printer and it is indeed used, but on Linux the set-printer doesn't seem to get used and instead CUPS takes care of where to print
As it is a Linux-only problem I think it's better handled in VCL
Created attachment 35068 [details] http://qa.openoffice.org/issues/show_bug.cgi?id=63169
For my first comment seems not to be placed correct I add again how to use the attached jar file to test the bug. Use following command: /usr/lib/sun-j2se5.0-jdk/bin/java -classpath /home/tobias/printbug.jar:/usr/lib/openoffice/program/classes/ridl.jar:/usr/lib/openoffice/program/classes/juh.jar:/usr/lib/openoffice/program/classes/jurt.jar:/usr/lib/openoffice/program/classes/unoil.jar:/usr/lib/openoffice/program/ de.twc.oocom.test.PrinterSelectionBug "FS1800" "/home/tobias/test.odt" Where the first parameter is your printer name (doesn't matter what you use, if you use CUPS the printout will be on the default printer. Second parameter is your file you want to print.
target
I have noticed the same behaviour when trying to print a writer document from a Java Program on a remote OO 2.x located on a remote Windows 2000 computer (OO is started in headless mode). I try to modify the printer name via XPrintable interface but it is always the default printer of the remote computer that is used. (The printer name is correct since I get it from a OO writer document. In fact, I use a OOBean to locally open a document in a SWT frame. When a user prints the document I intercepts the call, get the printer name associated to the document and delegates the printing to the remote OO). This bug looks like the 27022 issue.
Hi mvincent, indeed it seems to be the same as bug 27022. I can chose a printer and even a printer tray in OOo (Linux) when I connect to a existing OOo with an opened document. For me, -headless is not the reason (I tested -headless in Windows OOo 2.0.3 and it printed?!). If I just start OOo without any open document it does not work in Linux, too. If I then create a new document and try again to connect to OOo it works. Need more tests, please ask here. Greetings, Tobias PS: Changed priority and version
I have the same problem selecting a printer from a basic macro: printerprops(0).Name = "Name"; printerprops(0).Value = "myPrinterName" pDoc.setPrinter(printerprops()) will usually print to the default printer with OO 2.0.3 if myPrinterName is a cups printer (very rarely it works) and the macro is immediatily executed. OO 2.0.3 does not change the printer at all: if you do a getPrinter() after the setPrinter it is still "Generic Printer". But a small change helps. The following code always succeeds in setting the printer: printerprops(0).Name = "Name"; printerprops(0).Value = "myPrinterName" msgbox "blabla" pDoc.setPrinter(printerprops()) I tried wait 10000 instead of msgbox but this does not help. So I think there is some sort of race condition: if the macro starts before openoffice has completed its detection of cups printers these printers are simply not known when setPrinter is called. The msgbox transfers control back to writer which completes the detection and updates the printer list. When the user clicks ok the macro continues and can now set the cups printer.
this should be a duplicate of issue 62663 *** This issue has been marked as a duplicate of 62663 ***
closing duplicate
Is bug 27022 solved also?