On Tuesday 11 September 2007, Andreas Schlüns wrote:
> Hello Hal,
>
> >> The real problem you have ... printing is by default an
> >> asynchronous operation. And of course - if you try to dispose a
> >> document which is currently in printing state it can crash (at
> >> least it shouldnt ... but it can).
> >>
> >> The best solution: start the printing job with a well documented
> >> parameter "Wait=true". see css.view.PrintOptions for further
> >> details.
> >
> > So I can set a print option of "Wait" to "true" and my program will
> > wait until the document is printed?  Do I understand that properly?
> >  That would simplify several questions I've had along the way.
>
> It makes your XPrintable.print() call synchron !
> If your call returns the document was printed (at least the content
> was transfered completely to the underlying print queue of your
> system). That means you can close the document afterwards without any
> problems and you can shutdown the whole office without any problems.
>
> >> On the other side it can be important how do you close the
> >> document. Do you use dispose() or close(). Documentation say you
> >> have to preferr XClosable.close().
> >
> > That's what I'm using.
>
> OK. ... with close(true) I hope :-)
>
> >> Further its always a good idea to control
> >> the lifetime of a document without any exception and call
> >> close(false). Means - please do not deliver the ownership to the
> >> document itself. It can work for a while ... but if you close the
> >> application it can make trouble. Because all documents not
> >> finished within her jobs ... but closed with "false" does not know
> >> how they should handle these situation right. They can of course
> >> handle it right ... but mostly they dont do it :-)
> >
> > But if I use "Wait=true" for printing, then close immediately after
> > the doc has been printed, and only load in one at a time, then that
> > should eliminate any problems, right?
>
> Yes - and your code will be more readable and easy.
> There is no need to use polling code, sleeps, threads or listener.
> Only 3 lines of code are needed ...
>
> loadComponentFromURL()
> print()
> close()
>
> ... OK - excepting some further stuff to define all needed parameters
> :-)

I'm using this to define my print options:

        PropertyValue[] printOpts = new PropertyValue[2];
        printOpts[0] = new PropertyValue();
        printOpts[0].Name = "Name";
        printOpts[0].Value = sPrinter;
        printOpts[1] = new PropertyValue();
        printOpts[1].Name = "Wait";
        printOpts[1].Value = "true";

Originally I set the array length to 1 and not 2 and the last 3 lines 
are new.  If I break it down into two different PropertyValue[] 
objects, will setting the 2nd erase the first?  When using it as above, 
I get an error:

com.sun.star.lang.IllegalArgumentException: 
        at 
com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:275)
        at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:141)
        at 
com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:377)
        at 
com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:346)
        at 
com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:106)
        at 
com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:860)
        at 
com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:809)
        at 
com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:159)
        at 
com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:141)
        at $Proxy4.print(Unknown Source)
        at com.thresh.agent.TNOOo.listenToPrint(TNOOo.java:409)
        at com.thresh.agent.TNOOo.docPrinter(TNOOo.java:329)
        at com.thresh.agent.TNOOo.access$3(TNOOo.java:285)
        at com.thresh.agent.TNOOo$2.run(TNOOo.java:481)
        at java.lang.Thread.run(Unknown Source)

I can test it using two different objects for the property values, but 
since I'm using a computer with only one printer, I want to be sure I'm 
not overriding the printer name when I set the 2nd option.

Hal

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to