Hi Martin,
Thanks for the reply, but the requirement is in Ax 2012 and the requirement is like the user is printing packing slip while posting. That time they want to print one pdf which is attached to the batch through document handaling. Here i am using the code which i know that we can print any document from outside ax stored in some drive. that is WINAPI::SHellExecute(filename,’’,’’,‘Print’);. this is printing thedocument to the default printer set by the user always , not to the printer set by the user in print job setting where the packing slip is printing. So here i am getting the printer but need to change the printer to default so that it will print the docment there simultaneously with packing slip. after printing the report we can revert back the defalut printer to the original before.
the code i am using is
DocuRef docuRef;
DocuType docuType;
PrintJobSettings pjs;
container
printjobset;
SalesFormLetter cmaSalesFormLetter;
SRSPrintDestinationSettings printSettings;
int
i,defaultPrinter,counter;
str 500
printer,printer1,printerDetails,portname,printerDriver;
cmaSalesFormLetter = cmaSalesFormLetter_PackingSlipShipCreate::newPackingSlipShipCreate();
cmaSalesFormLetter.getLast();
printSettings =
new
SRSPrintDestinationSettings(cmasalesFormLetter.printerSettingsFormletter());
sysPrintOptions =
new
sysPrintOptions();
sysPrintOptions.setPrintJobSettings(SysPrintOptions::newPrintJobSettingsOnServer());
printer1 = printSettings.printerName();
pjs =
new
PrintJobSettings();
//pjs.setTargetPrintMedium::Printer);
for(i = 1
;i<pjs.getNumberOfPrinters();i++)
{
printer = pjs.getPrinter(i);
if
(printer == printSettings.printerName())
{
defaultPrinter = i;
portname = pjs.printerPortName();
printerDriver = pjs.printerDriverName();
break
;
}
}
counter++;
sysPrintOptions.setPrinter(defaultPrinter);
if
(_batch.RecId)
{
while select
docuRef
where
docuRef.RefCompanyId==_batch.company() &&
docuRef.RefTableId==_batch.TableId &&
docuRef.RefRecId==_batch.RecId
join
docuType
where
docuType.TypeId==docuRef.TypeId &&
docuType.DocuStructureType==DocuStructureType::cmaCert
{
if
(docuRef.RecId)
{
{
printerDetails =
strFmt(’ t/ “%1” “%2” “%3” “%4”’,
docuref.completeFilename(),
printSettings.printerName(),p
rinterDriver,portname);
WinAPI::shellExecute(docuref.completeFilename(),’’,’’
, #ShellExePrint);
Thanks
NIhar