Page 1 of 1

Issue with uno.Print in 3.4.1

Posted: Fri Oct 26, 2012 1:10 pm
by annasagina
In my java OO bean implementation the document background color is grey . While giving print I need print dialog to be launched and for that the background color I am changing to white for document so that print comes as whilte in background. Once print is done changing backthe background color of docuemnt to grey color.

Using below code to achieve that

However the uno.print doesn't wait till print completes in OO3.4.1. So when change the background to grey it changes the print preview doc color also to grey.
XDispatchProvider xDispatchProvider = (XDispatchProvider)UnoRuntime.queryInterface(XDispatchProvider.class, mBean.getDocument().getCurrentController());
helper.executeDispatch(xDispatchProvider, ".uno:PrinterSetup","", 0,null

Plus when I move around printer name in printer dialog the layout of document in my OO bean changes to printlayout from weblayout. Since print is not synchronous call in uno.print even I make back to weblayout moving around printer name in printer dialog will change the layout to pritn layout.

So I have two issues
1. Background to be changed while printing(For this I tried property PrintPagebackground to false , but first time print it doesn't reflect . From 2nd time print this works)
2. Maintaining the weblayout of dcoument in OO bean


Also I thought I will display printer Setup dialog to show printer(which is synchronus call) however I won't be knowing what user chose in printer setup so that I can send the printername in print method of XPrintable.

Any help is appreciated.

Re: Issue with uno.Print in 3.4.1

Posted: Fri Oct 26, 2012 2:18 pm
by B Marcelly
Hi,
Add property Wait in your PrintOptions.

Please don't ask several questions in the same thread.

Re: Issue with uno.Print in 3.4.1

Posted: Fri Oct 26, 2012 5:15 pm
by annasagina
Wait property is for Xprintable.print which doesn't displays printer dialog.

Since I need print dialog box I have to use uno.Print

Sorry never meant to ask multiple questions . It is just beacuse print is not synchronous call causing me above mentioned issues.

Re: Issue with uno.Print in 3.4.1

Posted: Fri Oct 26, 2012 8:21 pm
by B Marcelly
After the dispatcher command .uno:Print run a routine like this one (translation from Basic should be easy) :

Code: Select all

REM *** Basic ***
Sub waitEndOfPrint
Dim printInfos As Variant, again As Boolean, x As Long

Do
  wait(100) ' 100 ms
  printInfos = ThisComponent.getPrinter()
  for x = 0 to UBound(printInfos)
    if printInfos(x).Name = "IsBusy" then
      again = printInfos(x).Value
    end if
  next
Loop Until not again
End Sub
Property IsBusy is a Boolean. I tested this routine years ago.
Plus when I move around printer name in printer dialog the layout of document in my OO bean changes to printlayout from weblayout. Since print is not synchronous call in uno.print even I make back to weblayout moving around printer name in printer dialog will change the layout to pritn layout.
I don't understand the meaning of this paragraph. Maybe someone else can.
About OO bean, you should read this answer from Jürgen Schmidt.