Print PDF file to printer

Source : Palle Agermark on AX

ATTENTION : That’s work ONLY if you have Adobe Reader installed !

Just write this code (and adapt) :

static void pdfprint(Args _args)
{ 
    str                 adobeExe; 
    str                 adobeParm; 

    PrintJobSettings    printJobSettings = new PrintJobSettings(); 
    Dialog              dialog = new Dialog(); 
    DialogField         dialogFileName; 
    ;
    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); 
    }
}