Issue 63169 - Selecting printer in linux using Java/UNO not possible
Summary: Selecting printer in linux using Java/UNO not possible
Status: CLOSED DUPLICATE of issue 62663
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All Linux, all
: P4 Trivial
Target Milestone: ---
Assignee: philipp.lohmann
QA Contact: issues@api
URL: http://api.openoffice.org/servlets/Re...
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-14 15:09 UTC by tobiaskrais
Modified: 2013-02-24 21:10 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
http://qa.openoffice.org/issues/show_bug.cgi?id=63169 (5.22 KB, application/octet-stream)
2006-03-20 15:39 UTC, tobiaskrais
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description tobiaskrais 2006-03-14 15:09:03 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
Comment 1 stephan.wunderlich 2006-03-15 10:11:03 UTC
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
Comment 2 Mathias_Bauer 2006-03-15 10:49:15 UTC
As it is a Linux-only problem I think it's better handled in VCL
Comment 4 tobiaskrais 2006-03-20 15:49:24 UTC
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.
Comment 5 philipp.lohmann 2006-06-15 16:23:35 UTC
target
Comment 6 mvincent 2006-07-17 20:50:55 UTC
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.
Comment 7 tobiaskrais 2006-07-18 08:27:13 UTC
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
Comment 8 wolfgang_walter 2006-08-05 00:32:30 UTC
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.
Comment 9 philipp.lohmann 2006-08-07 10:19:30 UTC
this should be a duplicate of issue 62663

*** This issue has been marked as a duplicate of 62663 ***
Comment 10 philipp.lohmann 2006-08-07 10:20:45 UTC
closing duplicate
Comment 11 tobiaskrais 2006-08-08 07:44:54 UTC
Is bug 27022 solved also?