Uniface User Forum

 View Only
  • 1.  COM with Chrome in C/S mode

    Posted 08-12-2021 08:37

    Hello,

    In Client/server mode, someone knows if (and how) Uniface is able to communicate with Call out and signatures with Google Chrome ?

    We would like, from Uniface,  to transfer parameters to Chrome to display infos and graphics . 

    And receive parameters from Chrome in return (Json or xml)

    Thanks for any help

    Daniel




  • 2.  RE: COM with Chrome in C/S mode

    Posted 08-12-2021 09:28

    Hi Daniel,

    have you tried using Uniface HTML widget, which being based on CEF library, is the same engine used from Chrome?

    If you would like to simply get from internet a page (or an xml or a json...) why not using UHTTP component which is implementing an http/https request/response round trip? It is by far more simple! There are examples into documentation.

    Regards,
    Gianni



  • 3.  RE: COM with Chrome in C/S mode

    Posted 08-12-2021 12:29

    Hello Gianni,

    Thanks for your response.

    In fact the HTML Widget  is limited in some aspects.

    Some functions for the JS widgets are voluntary disabled:  like export to PDF for example.

    As we need the export functions for ke JS libraries we want tu use, , we are trying  to use directely a browser chrome for exple.

    Do you think it's can be possible or a hard way to do that ?

    Thks 

    Daniel



  • 4.  RE: COM with Chrome in C/S mode

    Posted 08-12-2021 12:58

    Hi Daniel,

    AFAIK there isn't any COM support in Chrome...

    I've understood you would like:
    - open a specific internet page
    - export the screen content into a PDF document, probably as an image

    If yes, just as a quick idea: could you embed that specific page in a dedicated HTML frameset?

    The external frameset part contains your program logic while the internal part(s) the specific internet page you need to save.

    Does it makes sense?

    Regards,
    Gianni



  • 5.  RE: COM with Chrome in C/S mode

    Posted 08-12-2021 16:59

    UHTTP component?

    I don't know this technic...  😔

    Where could I find detailled examples ?




  • 6.  RE: COM with Chrome in C/S mode

    Posted 08-12-2021 17:13

    Hi Daniel,

    more info on UHTTP HERE for U10.3 and HERE for U9.7.

    Regards,
    Gianni




  • 7.  RE: COM with Chrome in C/S mode

    PARTNER
    Posted 08-13-2021 08:08

    Hi Daniel,

    We encountered a similar issue with using a web application which generates reports that the user can dynamically change and then export to PDF.

    We can not use here UHTTP to download PDF  because the request use COOKIES and many other context value.

    To keep this functioning by displaying this application in the HTML widget, we have injected some javascript code into the web page which downloads the file, cuts it, encodes it in base 64 and send it  to UNIFACE end then create the file wth filedump function. 

    The solution is not very pretty, slow and the file must not exceed a size .

    So as soon as possible we prefer to use HTTP to download files.


    Gilles.



    Javascript :
    
     downloadFile = function (sUrl) {
            var http_request = new XMLHttpRequest();
            http_request.onreadystatechange = function () {
                if (http_request.readyState == 4) {
                    var array = new Uint8Array(http_request.response);
                     createLocalFile(array);
                }
            }
            http_request.open("GET", sUrl, true);
            http_request.responseType = 'arraybuffer';
            http_request.send();
        };
    
        createLocalFile = function (array) {
            var len = array.byteLength;
            var partOfFile = "";
    		var file = "HW" + (new Date()).getTime(); 
    		window.unifaceTriggers("dumpFile", file, 1, 1, ""); 
            for (var i = 0; i < len; i++) {
                partOfFile += String.fromCharCode(array[i]);
                if (i % 5e6 == 0 && i > 0) {
                    window.unifaceTriggers("dumpFile", file, 0, 1, btoa(partOfFile));
                    partOfFile = "";
                }
            }
            if (partOfFile.length > 0) {
                window.unifaceTriggers("dumpFile", file, 0, 1, btoa(partOfFile));
                partOfFile = "";
            }
            window.unifaceTriggers("openLocalFile", "", file);
        };
    
    
    Code uniface :
    
    trigger dumpFile
    Params
    	string pFileName: IN
    	numeric pNew : IN
    	string pContent : IN
    endParams
    Variables
    	string lDossier
    	raw content
    	lineardatetime currentDate
    EndVariables
    content=$decode("BASE64",pContent)
    lDossier=$concat($ldir(),"download\",$processinfo("pid"),"\")
    if(pNew==1)
    	if($lfileexists($concat(lDossier,"/",pFileName))==1)
    		lfiledelete $concat(lDossier,"/",pFileName)
    	endif
    endif
    if(pContent!="")
    	lfiledump/append/raw Content,$concat(lDossier,"/",pFileName)
    endif
    
    end