I've hidden the document with the property value "hidden" (see below) but it doesn't seem to be enough. The document will pop up and close itself in the user interface just before the document gets printed. How can I make it hidden under the whole process?
Code: Select all
string url = Path.GetFullPath(@"myDocument.odt");
var uri = new System.Uri(url);
converted = uri.AbsoluteUri;
XComponentContext oStrap = uno.util.Bootstrap.bootstrap();
XMultiServiceFactory oServMan = (XMultiServiceFactory)oStrap.getServiceManager();
oDesk = (XComponentLoader)oServMan.createInstance("com.sun.star.frame.Desktop");
PropertyValue[] propVals = new PropertyValue[1];
propVals[0].Name = "Hidden";
oDoc = oDesk.loadComponentFromURL(converted, "_blank", 0, propVals);
unoidl.com.sun.star.container.XEnumerationAccess xtextfields =
((unoidl.com.sun.star.text.XTextFieldsSupplier)oDoc).getTextFields();
unoidl.com.sun.star.container.XEnumeration enumaration = xtextfields.createEnumeration();
while (enumaration.hasMoreElements())
{
uno.Any field = enumaration.nextElement();
if (field.Value is unoidl.com.sun.star.text.XTextField)
{
string name = ((unoidl.com.sun.star.text.XTextField)field.Value).getAnchor().getString();
if (name == "CustomerName")
{
((unoidl.com.sun.star.text.XTextField)field.Value).getAnchor().setString(lblCustomerName.Text);
}
}
}
[...]
//PRINT SECTION
PropertyValue[] propValues = new PropertyValue[2];
propValues[0] = new PropertyValue { Name = "Wait", Value = new uno.Any(true) };
propValues[1] = new PropertyValue { Name = "CopyCount", Value = new uno.Any(Convert.ToInt16(intNumberOfCopies)) };
((XPrintable)oDoc).print(propValues);
oDoc.dispose();
oDoc = null;