OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Changing the default printer in a mail merge

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
probert
General User
General User


Joined: 13 Apr 2006
Posts: 16

PostPosted: Wed Jun 07, 2006 11:21 am    Post subject: Changing the default printer in a mail merge Reply with quote

We are moving from a Word/COM/MS JVM solution to a OOo/Sun JVM solution to create mail merges from our Web applications. So far, everything works fine except one thing : I don't know how to change the printer when the merge is done. I set the following properties :

Quote:
oObjProps.setPropertyValue("DataSourceName", nomBaseDonnees);
oObjProps.setPropertyValue("Command", nomTableDonnees);
oObjProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
oObjProps.setPropertyValue("OutputType",new Short(com.sun.star.text.MailMergeType.PRINTER));
oObjProps.setPropertyValue("DocumentURL", cheminDocMaitre);


But I don't see a property for setting the printer. In the MailMerge, I see a PrintOptions key, but I don't know how to use it and if I can set the printer.

I guess the other option would be to save the document in a directory that is part of a print server but I prefer to send the output directly to the correct printer (who is selected by the user on the Web interface).
_________________
OOo 2.02 on Mac OS X 10.3.9
Back to top
View user's profile Send private message
probert
General User
General User


Joined: 13 Apr 2006
Posts: 16

PostPosted: Thu Jun 08, 2006 10:49 am    Post subject: Reply with quote

Well, it seems I can't change printers when doing the merge directly to a printer. So I tried to save the documents in files, opening them and changing the printer with XPrintable. Problem is : even if I change the name, it still print on the default (generic) printer.

Code:
      try {
         File[] fichiers = rep.listFiles();
         for (int i = 0; i < fichiers.length; i++) {
            File fichier = fichiers[i];
            PropertyValue[] loadProps = new PropertyValue[0];       
            XComponent xComponent = mxComponentLoader.loadComponentFromURL("file://" + fichier.getAbsoluteFile(), "_blank", 0, loadProps);        
            XTextDocument xDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent);
            
            XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc);
            PropertyValue[] printerDesc = new PropertyValue[1];     
            printerDesc[0] = new PropertyValue();     
            printerDesc[0].Name = "Name";     
            printerDesc[0].Value = "Obelix";             
            xPrintable.setPrinter(printerDesc);                     
            PropertyValue[] printOpts = new PropertyValue[0];     
            PropertyValue[] props = xPrintable.getPrinter();
            for (int j = 0; j < props.length; j++) {
               System.out.println(props[j].Name + " : " + props[j].Value);
            }
            xPrintable.print(printOpts);            
         }
      } catch (Exception e) {
         System.err.println("Caught UNO Exception: " + e);
      }


props[j].Name is always "Generic Printer", it's never "Obelix" :-/
_________________
OOo 2.02 on Mac OS X 10.3.9
Back to top
View user's profile Send private message
MVinz
General User
General User


Joined: 28 Nov 2005
Posts: 16
Location: Montpellier - France

PostPosted: Mon Jul 17, 2006 7:43 am    Post subject: Changing printer name through XPrintable has no effects... Reply with quote

Hi,

I have an OO 2.0 that run in headless mode on a Windows 2000 server. Using XPrintable interface I also try to modify the printer name (the Java program executes on another computer). However, it always print on the server default printer...
Did you get more information since your last post ?

thanks
Vincent
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group