That's because even if you pass printSettings parameters those are overriden by the controller class.
In AX 2009 there was a useful method called LockDestinationProperties in printSettings parameters that solve this problem, but this is gone in AX 2012.
So, If you want to reenable this feature, you have to do this:
Open the class SrsPrintMgmtFormLetterController and change those methods:
void public abstract class SrsPrintMgmtFormLetterController extends SrsPrintMgmtController
{
FormLetterReport formLetterReport;
// Begin - Modify by lmattiuz on 27/06/2012
boolean DEVLockDestinationProperties;
SRSPrintDestinationSettings DEVfixedprintSettings;
// End - Modify by lmattiuz
}
// Begin - Modify by lmattiuz on 27/06/2012 - Project: 120301_DevopmentTools_DEV
public Boolean DEVparmLockDestinationProperties(Boolean _DEVLockDestinationProperties = DEVLockDestinationProperties)
{
DEVLockDestinationProperties = _DEVLockDestinationProperties;
return DEVLockDestinationProperties;
}
protected void outputReport()
{
// Begin - Modify by lmattiuz on 27/06/2012 - Project: 120301_DevopmentTools_DEV
// Description:
if(DEVLockDestinationProperties)
formLetterReport.getCurrentPrintSetting().parmPrintJobSettings(DEVfixedprintSettings);
// End - Modify by lmattiuz
// execute report.
if(formLetterReport)
{
formLetterReport.execute();
}
}
public SysOperationStartResult startOperation()
{
// Begin - Modify by lmattiuz on 27/06/2012 - Project: lmat_120301_DevopmentTools_DEV
// Description:
if(DEVLockDestinationProperties)
DEVfixedprintSettings = this.parmReportContract().parmPrintSettings();
// End - Modify by lmattiuz
this.init();
return super();
}
Then you can print reports in PDF as you usually do:
protected void printReportPdf(Common _record)
{
args args = new args();
CustInvoiceJour custInvoiceJour = _record;
SRSPrintDestinationSettings printSettings;
SalesInvoiceController controller = new SalesInvoiceController();
args.record(_record);
pdfPath = WinAPI::getTempPath() + custInvoiceJour.InvoiceId + ".pdf";
// imposta nome report
controller.parmReportName(ssrsReportStr(SalesInvoice, Report));
// get print settings from contract
printSettings = controller.parmReportContract().parmPrintSettings();
// set print medium
printSettings.printMediumType(SRSPrintMediumType::File);
printSettings.fileFormat(SRSReportFileFormat::PDF);
printSettings.overwriteFile(true);
printSettings.fileName(pdfPath);
// forzo che non vengano cambiati i parametri di stampa che gli passo io
controller.DEVparmLockDestinationProperties(true);
// suppress the parameter dialog
controller.parmShowDialog(false);
controller.parmArgs(args);
// start operation
controller.startOperation();
}