Selecting Output Bin When Printing

Creating a macro - Writing a Script - Using the API

Selecting Output Bin When Printing

Postby groverblue » Wed Mar 26, 2008 6:24 pm

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

I know how to select the input tray:

PrinterPaperTray is being used as the input tray.

These are my defined trays:

Code: Select all   Expand viewCollapse view
Bypass Tray
Tray 1
Tray 2

Inner Tray 1 (Lower)

This is the code I use to set the input tray.

Code: Select all   Expand viewCollapse view
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?
Posts: 40
Joined: Wed Mar 26, 2008 6:17 pm

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 11 guests