XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(
XPrintable.class, xDoc);
PropertyValue[] printerDesc = new PropertyValue[1];
printerDesc[0] = new PropertyValue();
printerDesc[0].Name = "Name";
printerDesc[0].Value = sPrinterName;
xPrintable.setPrinter(printerDesc);
// set print options if necessary
//PropertyValue[] printOpts = new PropertyValue[1];
//printOpts[0] = new PropertyValue();
//printOpts[0].Name = "Pages";
//printOpts[0].Value = "1";
xPrintable.print(null);
// maybe use a print listener to check your print jobs before
terminate
I found I had to use a print listener. If I didn't, then after
printing, if I tried to close a doc, I got errors.
You can also add this property to your printOpts - then XPrintable.print() will
be synchronous.
new PropertyValue("Wait", 0, Boolean.TRUE, PropertyState.DIRECT_VALUE);