1. Sathishkumar S
  2. PowerBuilder
  3. Tuesday, 8 February 2022 11:45 AM UTC

Hello!1.In web browser control, PB 2019 R3 while printing from user event unable to print from print().

I am having web browser control to display pdf documents(which is converted from images and docs). which has to be stamped then to print from the user event instead of using the print icon in the web browser control.

I am using citrix development environment


I am using below function unable to do printing

wb_1.navigate( 'file:///' + ls_temp )

print() --> I am getting print dialogue to click print but the printing is not happening(only one activity)

 

but if I use the below codes I am able to print with 2 steps

I have to select the printer from PrintSetup() then I have to print it from the print() function,

in this case user have to select printer once then have to click print (the user have to do 2 activities [selecting the printer and then click print] instead of just 1 activity like print)

wb_1.navigate( 'file:///' + ls_temp )

PrintSetup() --> Activity 1 selecting the printer

print()--> Activity 2 Print

Kindly help me with any alternate way.

 

I have also tried below code to setup the printer but still unable to get the result

long ll_place
string ls_setprn
string ls_prntrs = PrintGetPrinters ( )
ll_place=pos (ls_prntrs, "~n")
mle_1.text = PrintGetPrinters ( )
ls_setprn = Left (ls_prntrs, ll_place - 1)
PrintSetPrinter (ls_setprn)

 

2. Is there way to access the print icon in the web browser control.

Is there any way to access the print icon in the web browser control to manipulate some additional activities(adding stamp before printing it).

3. Is there any tutorial or help document which I can refer for web browser control

 

Thank you,

Sathishkumar

 

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 9 February 2022 10:03 AM UTC
  2. PowerBuilder
  3. # Permalink

What I think is that your print() command is being issued before the navigate() has finished.

When you are debugging, there's a delay while you step through the code, so that could be an explanation as to why it works in debug mode.

Try this and see if that solves the problem:

wb_1.navigate( 'file:///' + ls_temp )
yield()
sleep(2)
print()

As far as I remember, there's no event that indicates when the navigate has completely finished. There's one event called "navigationProgressIndex" which has a parameter progressIndex.
You would expect that when the progressIndex = 100, that the navigation would have finished, but I found that this event will be fired an undetermined amount of times, receiving the same 100 value. Only the last time that this event is fired with a value of a 100, the navigation has really finished.

The PB help says this: "The NavigationProgressIndex event will be triggered for uncertain times even if the page has been 100% loaded."
In my opinion the part where it says "even if the page has been 100% loadedis NOT correct. It's only 100% loaded the last time that event fires, so the event is only run once when the page is fully a 100% loaded.

regards

Comment
  1. Sathishkumar S
  2. Wednesday, 9 February 2022 10:52 AM UTC
Thank you very much Miguel, it works now.

Yes, You are correct I understand now while I am debugging there is a delay which will not be there when I run the application.

Thank you very much once again.

Regards

Sathishkumar.
  1. Helpful 2
There are no comments made yet.
Tracy Huang @Appeon Accepted Answer Pending Moderation
  1. Friday, 11 February 2022 02:48 AM UTC
  2. PowerBuilder
  3. # 1

Dear Sathishkuma,

I checked with the engineer and they suggest the following scripts should also resolve your issue (please help us verify):

//Instance Variable: Boolean  ib_init

If Not ib_init Then

    If progressindex = 100 Then

        ib_init = true

        print()

     End If

End If

The engineer said the Navigate function is executed asynchronously, therefore, it is recommended that you use the NavigationProgressIndex event to determine whether the Navigate function is completed before executing the Print function. You can check the value of the NavigationProgressIndex event, and if the event receives the first value of 100, it means the page is 100% loaded. (This is a little bit different from what Miguel has observed, so we are still verifying and hope you can help us verify too).

Regards

Tracy

Comment
  1. Miguel Leeuwe
  2. Friday, 11 February 2022 12:05 PM UTC
Hi Tracy,

I'm not aware of any improvements done on this topic. So maybe someone has fixed something?

Please see: https://www.appeon.com/standardsupport/track/view?id=5476

  1. Helpful
  1. Tracy Huang @Appeon
  2. Monday, 14 February 2022 02:39 AM UTC
Hi Miguel,

Thank you for referring me to more information. Yes, you are right. The return value of 100 does not always indicate page 100% loaded, especially if the page is complicated. So I think maybe this limitation should be documented like this (please feel free to add comments).



The Navigate function is executed asynchronously. Therefore, if the next script must be executed after the Navigate function is completed, then it is recommended to check the value of the NavigationProgressIndex event, and only after the event receives the value of 100 (which means the page is 100% loaded), the next script should be executed. For example,



String ls_temp

ls_temp = "D:/PB/PB2019R3/WebBrowser/JavaScript/ManuTestCase/html/JavaScript_011.html"

wb_1.navigate( 'file:///' + ls_temp )

ib_init = false //Instance Variable: Boolean ib_init



If Not ib_init Then

If progressindex = 100 Then

ib_init = true

print()

End If

End If



But if the page to be loaded is complicated (such as loading multiple frames, embedding large amount of data, associating and accessing data from other websites, having complex logics or deep hierarchical structure etc.), the value of 100 may not indicate that the page is completely loaded. In such case, you can consider using Yield and Sleep functions to delay executing the next script. For example,



wb_1.navigate( 'file:///' + ls_temp )

yield()

sleep(2)

print()



Regards

Tracy
  1. Helpful
  1. Sathishkumar S
  2. Wednesday, 16 February 2022 13:32 PM UTC
Thank you Tracy

I have used the below part which is working fine for me.

wb_1.navigate( 'file:///' + ls_temp )



yield()



sleep(2)



print()



Thanks & Regards

Sathishkumar
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 8 February 2022 16:30 PM UTC
  2. PowerBuilder
  3. # 2

Hi,

Have you tried deploying a PB.INI file with this setting in it?

 

[Data Window]
Citrix=1

Maybe it will help resolve some of the problem.

regards

Comment
  1. Sathishkumar S
  2. Wednesday, 9 February 2022 09:44 AM UTC
Hi Miguel,



I have tried after including it in the PB.INI

I am still in development stage while debugging print is happening for the below code



wb_1.navigate( 'file:///' + ls_temp )



print()



but if I run normally from PB without debug mode then print is not happening some how print() function is not working

but if I add any message box before that then the print is happening (unnecessarily we cannot give message to the user) .



I don't know what was the issue with this. If I can get some info why it is not happening like that or any other alternative way.





Thank you

Sathishkumar
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.