title: How to open PDF created with flying-saucer/itext with a print dialog
body: <p><I>Some background to this question can be found at <a href="https://stackoverflow.com/questions/9435473/check-printing-with-java-jsp">Check printing with Java/JSP</a> and <a href="https://stackoverflow.com/questions/9638989/create-a-print-only-pdf-with-itext">Create a &quot;print-only&quot; PDF with itext</a></I></p>
  
  <p>I have been able to successfully create and open a PDF with a print dialog using iText-2.0.8 and the following code:</p>
  
  <pre><code>String outputFile = "firstdoc.pdf";
  Document document = new Document();
  PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile));
  writer.setOpenAction(new PdfAction(PdfAction.PRINTDIALOG)); 
  document.open();
  document.add(new Paragraph("TEST"));
  document.close();
  </code></pre>
  
  <p>I have also been able to use flying-saucer to generate a PDF from XHTML using the following code:</p>
  
  <pre><code>String inputFile = "firstdoc.xhtml";
  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>
  
  <p>However, I can't seem to get the two to work together...</p>
  
  <p>I would like to create the PDF using flying-saucer as in the 2nd code block <b>and</b> I would like to set the open action of that PDF to <code>PdfAction.PRINTDIALOG</code>.</p>
  
  <p>How can I get these two sets of code to work together such that a flying-saucer created PDF opens with a print dialog initially?</p>