Selenium: How to verify PDF content?

import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.util.PDFTextStripper;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;

public class PdfReadWrite {

public static void main(String args[]) throws InterruptedException,
IOException {

WebDriver driver = new FirefoxDriver();
driver.get(“http://www.nikon.co.in/tmp/IN/2419865273/3760176746/2586568015/286546384/3855120363/4043737636/4196861409/3724334581/3315196638.pdf”);
;
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

// create poiter to URL
URL url = new URL(driver.getCurrentUrl());

// Buffer the file into temporary storage
BufferedInputStream sourceFile = new BufferedInputStream(
url.openStream());

PDFParser parser = new PDFParser(sourceFile);
parser.parse();

// put PDF text in String variable
String textPdf = new PDFTextStripper().getText(parser.getPDDocument());

// in case you want to see where the sub string is
System.out.println(textPdf.indexOf(“D3X Body only”));

// Apply Asserts
try {
Assert.assertTrue(textPdf.contains(“D309X Body only”),
“Text ‘D3X Body only’ is not found”);
} catch (AssertionError e) {

}
// close the document
parser.getPDDocument().close();
driver.quit();

}// main

}// class

//in case you find error, please check you have all the jars mentioned in the import section