Results 1 to 4 of 4

Thread: Return value from CallDevToolsProtocolMethod from RC6/cWebView2

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2026
    Posts
    2

    Return value from CallDevToolsProtocolMethod from RC6/cWebView2

    I host WebView2 in my vb6 app using RC6. I would like to call CallDevToolsProtocolMethod Page.printToPDF and get the base64 of the pdf back, but I believe the current version of RC6 does not provide a return value when calling CallDevToolsProtocolMethod, probably because it is async. I tried to check the various events but none trigger, so it seems there is no way to get the return value from CallDevToolsProtocolMethod Page.printToPDF.

    Any ideas?

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,172

    Re: Return value from CallDevToolsProtocolMethod from RC6/cWebView2

    Quote Originally Posted by pawlos2nd View Post
    I tried to check the various events but none trigger, so it seems there is no way to get the return value from CallDevToolsProtocolMethod Page.printToPDF.

    Any ideas?
    Did you try JSMessage event? It can be "manually" triggered by your JS code with something like vbH().RaiseMessageEvent('title_change', document.title) -- this will trigger JSMessage with sMsg = "title_change" and sMsgContent populated accordingly.

    Try implementing your async handler in JS so that on ready it just calls back into VB6 with simple vbH().RaiseMessageEvent passing unique 'pdf_ready' message type with base64 encoded PDF in second sMsgContent parameter.

    cheers,
    </wqw>

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2026
    Posts
    2

    Re: Return value from CallDevToolsProtocolMethod from RC6/cWebView2

    I appreciate your answer, but I dont think it works because Page.printToPDF is a DevTools Protocol method. Page JS cannot invoke CDP — there is no window/chrome.webview API for it, so JS has no "on ready" event and never receives printToPDF's base64?

  4. #4
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,172

    Re: Return value from CallDevToolsProtocolMethod from RC6/cWebView2

    Yes, I see -- my bad I didn't realize CallDevToolsProtocolMethod is a method of cWebView2 which you probably call with something like

    Code:
       '--- CDP options: sizes in INCHES (A4 = 8.27 x 11.69)
       sParams = "{""printBackground"":true," & _
                 """paperWidth"":8.27,""paperHeight"":11.69," & _
                 """marginTop"":0.4,""marginBottom"":0.4," & _
                 """marginLeft"":0.4,""marginRight"":0.4," & _
                 """preferCSSPageSize"":true}"
    
       '--- Invoke CDP; returns {"data":"<base64>"}
       Call WV.CallDevToolsProtocolMethod("Page.printToPDF", sParams)
    Olaf will have to chime in but by the looks of it I think there is probably a completion event missing by the wrapper the same way DocumentTitleChanged event is missing and has to be handled in JS as a workaround.

    cheers,
    </wqw>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width