HTML Widget, cef3, PDFs and Find

Author: i.sharp@pcisystems.co.uk (Iain Sharp)

So, we are updating to 9.7, and have switched from the Adobe OCX to the HTML widget and thus the CEF3 environment.  I have worked out how to fire javascripts within the HTML widget, and a google search tells me there is support for the Find function within Java in the cef3 environment. However, I can't work out how to connect the dots to get it to work, does anyone have any experience of this?  Iain

7 Comments

  1. Hello Iain,   can you give a short example of your code?


    Author: Lauterbach (norbert.lauterbach@infraserv.com)
  2. Okay,  

    v_encoded = _string from database which is pdf data_
     v_encoded = $encode("BASE64", v_encoded)
     v_pdf = $encode("USTRING", v_encoded)
    v_script = "<script>"
    v_script = $concat(v_script,"%%^","function PCIFind(text) {")
    ;v_script = $concat(v_script,"%%^"," CefBrowserHost::Find(text);")
    v_script = $concat(v_script,"%%^"," document.getElementById('pdfview').Find(text);")
    ;v_script = $concat(v_script,"%%^"," window.alert(%%"boo%%");")
    v_script = $concat(v_script,"%%^","}")
    v_script = $concat(v_script,"%%^","</script>")
     v_html = $concat("",v_script,"<body><object id=%%"pdfview%%" name=%%"tester.pdf %%" type=%%"application/pdf%%" width=%%"100% %%" height=%%"97% %%" data=%%"data:application/pdf;base64,")
     ; v_html = "<body><object type=%%"application/pdf%%" width=%%"100% %%" height=%%"100% %%" data=%%"%%prt_repb_id%%%.pdf"
     
     v_html = $concat(v_html,v_pdf)
     v_html = $concat(v_html,"%%"></object></body>")
     d_html/init = v_html
     

      And then in the button.  

    $fieldhandle(D_HTML)->$widgetoperation("JS:PCIFind","32242")

      The code works when the JS is window.alert, but we can't work out what to call to connect to the cef viewer find option. (Which I am only assuming is there from googling the issue, I have no proof, but I think its CefBrowser...::Find)


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  3. Hi Iain, I don't think that you can access the Find function of the class CefBrowserHost from JavaScript. Uniface, or better said the HTML widget, would need to expose this function in Proc (e.g. through $widgetoperation). I guess this would be a valid candidate for the wish list. In JavaScript the window object has a method called find() - I can see that you've already found this. But this method apparently does not work with the PDF plugin. Confused Kind regards, Daniel


    Author: diseli (daniel.iseli@uniface.com)
  4. That's a shame.  I am also running afoul of the fact that the 'save' icon on the cef browser menu doesn't save anything. This seems, from my limited googling, to be a long known issue with chrome, but I can't work out if there's anything I can do about it.  Also, and for information for anyone following this, the code above loads the pdf into the 'data' attribute of the object. It would appear from actual production tests that either the encode function, the contents of the html widget or the cef renderer have a size limit on the data encoded.  We have had to release a patch to replace the object/data with an object/source, and return to using a file on the hard drive for 'large' pdf files, (~> 1.5Mb), the renderer slowed down exponentially and then failed to display the data on larger data sets. 


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  5. Okay, additional question, if, with focus on the HTML widget, I press Ctrl-[ or Ctrl-] I can rotate the image.  Can I get uniface to replicate pressing these keys on the relevant widget.  I have tried macro "^130[" to no avail


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  6. Iain, I haven't tried this - in theory some JS could be the solution as outlined here; http://www.quirksmode.org/js/keys.html Regards, Knut


    Author: Knut (knut.dybendahl@gmail.com)
  7. That page seems to more about picking up the keys in java. If I am looking at the screen I can press Ctrl-[ or Ctrl-] and have the effect I am looking for, what I want to do is to click a panel button, or a command button, and have Uniface 'send' Ctrl-[ to the html widget.  Iain


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)