title: Print SSRSReport to file (.PDF)
body: <p>I need to find a way to "print" a <code>SrsReport</code>, in my case <code>SalesInvoice</code>, as .PDF (or any kind of file) to a specific location.</p>
  
  <p>For this I modified the <code>SRSPrintDestinationSettings</code> to output the SalesInvoice-Report as a .PDF:</p>
  
  <pre><code>settings = controller.parmReportContract().parmPrintSettings();
  settings.printMediumType(SRSPrintMediumType::File);
  settings.fileFormat(SRSReportFileFormat::PDF);
  settings.overwriteFile(true);
  settings.fileName(@'\\AXDEV\Bottomline\Test\test.pdf');
  </code></pre>
  
  <p>Somehow this gets ignored and I recive a Email with the report as .PDF attached. </p>
  
  <p>For example this will run on ax 2012 but won't print to PDF for me.</p>
  
  <pre><code>SRSPrintDestinationSettings     settings;
  CustInvoiceJour         custInvoiceJour;
  SrsReportRunController          controller = new SrsReportRunController();
  PurchPurchaseOrderContract  rdpContract = new PurchPurchaseOrderContract();
  SalesInvoiceContract    salesInvoiceContract = new SalesInvoiceContract();
  
  select firstOnly1 * from custInvoiceJour where custInvoiceJour.SalesId != "";
  
  // Define report and report design to use
  controller.parmReportName(ssrsReportStr(SalesInvoice,Report));
  // Use execution mode appropriate to your situation
  controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
  
  
  rdpContract.parmRecordId(custInvoiceJour.RecId);
  controller.parmReportContract().parmRdpContract(rdpContract);
  
  // Explicitly provide all required parameters
  salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
  controller.parmReportContract().parmRdpContract(salesInvoiceContract);
  salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
  
  // Change print settings as needed
  settings = controller.parmReportContract().parmPrintSettings();
  settings.printMediumType(SRSPrintMediumType::File);
  settings.fileFormat(SRSReportFileFormat::PDF);
  settings.overwriteFile(true);
  settings.fileName(@'\\AXDEV\Bottomline\Test\test.pdf');
  
  //tokens = settings as SrsPrintDestinationTokens();
  //controller.parmPrintDestinationTokens(null);
  
  //Suppress report dialog
  controller.parmShowDialog(false);
  // Execute the report
  controller.startOperation();
  </code></pre>
  
  <p>Questions:
  Is this the correct way to print a srsReport to .pdf?
  Am I passing/setting the printerSettings correctly?
  Where does it say "Send Email"?</p>
  
  <p>EDIT: Code is working fine. We are using external code of a company which simply doesnt implement this.
  Use the cleaner code of Alex Kwitny</p>