Page 1 of 1

Selecting Output Bin When Printing

Posted: Wed Mar 26, 2008 6:24 pm
by groverblue
Does anyone know how to select the output bin/tray when printing an OOo document from Java?

Below is a summary of the post I made to oooforum.org:
(http://www.oooforum.org/forum/viewtopic.phtml?t=65999)

I know how to select the input tray:

PrinterPaperTray is being used as the input tray.

These are my defined trays:

Code: Select all

INPUT TRAYS:
Bypass Tray
Tray 1
Tray 2

OUTPUT TRAYS
Inner Tray 1 (Lower)
This is the code I use to set the input tray.

Code: Select all

XTextDocument aTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xcomp);
XText xText = aTextDocument.getText();
XTextCursor xTextCursor = xText.createTextCursor();
XPropertySet xTextCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
String pageStyleName = xTextCursorProps.getPropertyValue("PageStyleName").toString();
XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, aTextDocument);
XNameAccess xFamilies = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xSupplier.getStyleFamilies());
XNameContainer xFamily = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xFamilies.getByName("PageStyles"));
XStyle xStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, xFamily.getByName(pageStyleName));
XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle);

xStyleProps.setPropertyValue("PrinterPaperTray","Tray 1");
There doesn't seem to be a way to set the output tray directly, but there must be a way to access the same driver information that is saved within the PrintSetup section of a document. I mean, OOo Writer can access and save this information, why can't it be done through Java for my purposes?