XComponent xcomponent = xcomponentloader.loadComponentFromURL(
sUrl.toString(), "_blank", 0,
new PropertyValue[0] );
// Querying for the interface XPrintable on the loaded document
XPrintable xprintable =
( XPrintable ) UnoRuntime.queryInterface( XPrintable.class, xcomponent );
// Setting the property "Name" for the favoured printer (name of IP address)
PropertyValue []propertyvalue = new PropertyValue[ 1 ];
propertyvalue[ 0 ] = new PropertyValue();
propertyvalue[ 0 ].Name = "Name";
propertyvalue[ 0 ].Value = args[ 0 ];
// Setting the name of the printer
xprintable.setPrinter( propertyvalue );
// Setting the property "Pages" so that only the desired pages will be printed.
propertyvalue[ 0 ] = new PropertyValue();
propertyvalue[ 0 ].Name = "Pages";
propertyvalue[ 0 ].Value = args[ 2 ];
// Printing the loaded document
xprintable.print( propertyvalue );
System.exit(0);
}
catch( Exception exception ) {
System.err.println( exception );