How to test pdf displayed inside WebView

I want to test PDF which contains terms and conditions, but this displayed as WebView. To switch to WebView, I am using below code.

String strWebContextName = getContexts().stream().filter(ctx → ctx.contains(“WEBVIEW_”)).findAny().orElse(null);
if (Objects.nonNull(strWebContextName)) {
utils.log().info("WEB CONTEXT NAME " + strWebContextName);
((AndroidDriver) getBaseMobileDriver()).context(strWebContextName);

Then locate the script tag and get the content

@FindBy(xpath = “//script[@type="text/javascript" and contains(text(),"_init")]”)
private WebElement webElementPdfPath;

String htmlCode = (String) ((JavascriptExecutor) getBaseMobileDriver()).executeScript(“return arguments[0].innerHTML;”, webElementPdfPath);

After this I don’t know how to proceed. like to extract pdf URL and process. do I need to download the pdf and then compare the text