get the contents from the webview using javafx

adesh singh picture adesh singh · Jan 11, 2013 · Viewed 28k times · Source

I am working on a swing application using JAVA FX controls . In my application i have to take print out the html page displayed in the webview . What I am trying is to load the html content of webview in a string with the help of HtmlDocuement.

To load the content of html file from web view,I am using the following code but its not working:

try
{
    String str=webview1.getEngine().getDocment().Body().outerHtml();
}
catch(Exception ex)
{
}

Answer

iTake picture iTake · Dec 29, 2013
String html = (String) webEngine.executeScript("document.documentElement.outerHTML");