title: How to convert url of html page to pdf in java using iText & flying saucer?
body: <p>I've just downloaded xhtmlrenderer and iText jar files. I can make pdf files by using these jars.</p>
  
  <p>What I exactly want is: 
  I need to create pdf if I give one valid URL (say "<code>https://xhtmlrenderer.dev.java.net/news.html</code>") in the place of "inputFile". Is it possible with flying saucer and iText?</p>
  
  <p>If yes, please guide me to achieve this.</p>
  
  <p>Also, when I'm trying to run the below code, I'm getting error: stream closed</p>
  
  <pre><code>import java.io.*;
  import com.lowagie.text.DocumentException;
  import org.xhtmlrenderer.pdf.ITextRenderer;
  
  public class FirstDoc {
  
      public static void main(String[] args) 
              throws IOException, DocumentException {
          String inputFile = "samples/sql.html";
          String url = new File(inputFile).toURI().toURL().toString();
          String outputFile = "firstdoc.pdf";
          OutputStream os = new FileOutputStream(outputFile);
  
          ITextRenderer renderer = new ITextRenderer();
          renderer.setDocument(url);
          renderer.layout();
          renderer.createPDF(os);
  
          os.close();
      }
  }
  </code></pre>