title: How can I programatically print a DataReport to a pdf file?
body: <p>I'm updating old VB6 code to save its DataReports out to a PDF, rather than bringing up a print dialog.</p>
  
  <p>I cannot simply write the PDF within the code (using a VB6 PDF library, etc.), since all our software already uses DataReports, and writing print code for each one would be tedious, at best. Currently, the process requires an employee to print the DataReport to a PDF print driver, naming it manually and saving it to where it needs to go. I need to automate this all, so that the name and location of the saved PDF can be specified programatically, rather than entered by hand.</p>
  
  <p>The best solution would be if DataReport simply had a <code>.SaveToPdf(filename)</code> routine. Worst-case scenario, I see myself automating the process using <code>SendKeys</code>. However, this solution needs to work in an environment with multiple possible printers (so the PDF print driver might not be the default,) and on Windows XP, Vista, or 7.</p>
  
  <p>I've fruitlessly tried Googling the problem, which returns only tutorials on how to do it by hand, much as we do now.</p>