web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Dynamics 365 Vs Me / Print PDF files from AX X++...

Print PDF files from AX X++ code

Deepak Agarwal Profile Picture Deepak Agarwal 8,624

Print External PDF file from AX 

This job illustrates how we can print an external PDF file to a printer chosen in AX through X++ code. Here a code sample (X++ job) to do this.

static void theAxapta_pdfprint(Args _args)
{
PrintJobSettings printJobSettings = new PrintJobSettings();
Dialog dialog = new Dialog();
DialogField dialogFileName;
str adobeExe;
str adobeParm;
;
dialogFilename = dialog.addField(typeid(FilenameOpen));

if (dialog.run())
{
printJobSettings.printerSettings('SysPrintForm');
adobeExe = WinAPI::findExecutable(dialogFileName.value());

adobeParm = strFmt(' /t "%1" "%2" "%3" "%4"',
dialogFileName.value(),
printJobSettings.printerPrinterName(),
printJobSettings.printerDriverName(),
printJobSettings.printerPortName());

winAPI::shellExecute(adobeExe, adobeParm);
}
}

-Harry

This was originally posted here.

Comments

*This post is locked for comments