I am trying to convert a webpage into pdf but web page is getting load and some jquery function needs to executed on page to bring dynamic data which takes time hence page loading is not a problem here but dynamic addition of data via jquery is troubling me alot. below is code which i am using to generate pdf
String pathToPhantomJS = "/usr/bin/phantomjs" //path to your phantom js
String pathToRasterizeJS = "/home/tothenew/Desktop/rasterize.js" //path to your rasterize.js
String paperSize = "A4"
String url = "https://www.google.co.in/" //url of your web page to which you want to convert into pdf
File outputFile = File.createTempFile("sample", ".pdf") //file in which you want to save your pdf
//TODO: also do exception handling stuff . i am not doing this for simplicity
Process process = Runtime.getRuntime().exec(pathToPhantomJS + " " + pathToRasterizeJS + " " + url + " " + outputFile.absolutePath + " " + paperSize);
int exitStatus = process.waitFor(); //do a wait here to prevent it running for ever
if (exitStatus != 0) {
log.error("EXIT-STATUS - " + process.toString());
}
is there is way in java i can tell wait for page to be load or what should i do so that phantom js will capture the webpage only after its get loaded completely.