Open and print a document while it's hidden in the UI. C#

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Open and print a document while it's hidden in the UI. C#

Postby terina » Wed Oct 22, 2014 4:35 am

Is it possible to open an OO writer document, fill textboxes, print the document and close it without showing the whole process in the user interface?

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   Expand viewCollapse view
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("");

PropertyValue[] propVals = new PropertyValue[1];
propVals[0].Name = "Hidden";

oDoc = oDesk.loadComponentFromURL(converted, "_blank", 0, propVals);

  xtextfields =
  enumaration = xtextfields.createEnumeration();

while (enumaration.hasMoreElements())
                    uno.Any field = enumaration.nextElement();
                    if (field.Value is
                        string name = ((;

                        if (name == "CustomerName")





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)) };
oDoc = null;

If i don't get the code above to work fine, another possibility could be to open a copy of the OO writer document through C#. The user could then manually print the document. Is this possible to implement?
OpenOffice 4.0.1 on Windows 7
Posts: 2
Joined: Mon Jun 02, 2014 2:52 pm

Re: Open and print a document while it's hidden in the UI. C

Postby B Marcelly » Wed Oct 22, 2014 8:16 am

Set the propVals[0].Value at True.
Bernard 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
B Marcelly
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest