Converting page direct to pdf from terminal

#Interactive converting the webpage direct to pdf save file format
#

URL pageURL = new URL("http://localhost.com"+queryStr);  
BufferedReader in = new BufferedReader(new InputStreamReader(pageURL.openStream()));  
BufferedWriter bw = new BufferedWriter(new FileWriter("myTempFile"+request.getSession().getId()+".html"));  
String inputLine;  
              
while ((inputLine = in.readLine()) != null)  
      bw.write(inputLine);  
  
in.close();  
bw.flush();  
bw.close();  
          
          
String inputFile = "myTempFile"+request.getSession().getId()+".html";  
String url = new File(inputFile).toURI().toURL().toString();  
String outputFile = "pdfSave.pdf";  
OutputStream os = new FileOutputStream(outputFile);  
ITextRenderer renderer = new ITextRenderer();  
renderer.setDocument(url);  
renderer.layout();  
  
try {  
    renderer.createPDF(os);  
} catch (DocumentException e) {  
      e.printStackTrace();  
}