Issue with uno.Print in 3.4.1

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
annasagina
Posts: 5
Joined: Tue Oct 16, 2012 10:22 am

Issue with uno.Print in 3.4.1

Post 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.
Open office 3.4.1 Windows7
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Issue with uno.Print in 3.4.1

Post by B Marcelly »

Hi,
Add property Wait in your PrintOptions.

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

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
annasagina
Posts: 5
Joined: Tue Oct 16, 2012 10:22 am

Re: Issue with uno.Print in 3.4.1

Post 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.
Open office 3.4.1 Windows7
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Issue with uno.Print in 3.4.1

Post 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.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Post Reply