Pages

Monday, January 14, 2008

Print PDF files from AX to specific printer

This job illustrates how you can print an external PDF file to a printer choosen in AX:

static void 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);
}
}

4 comments:

Anonymous said...

Palle,
This is a perfect article I was just havind this problem!

Keep up blogging ;-)

Philippe Vanstipelen
Edan Business software

TKemmann said...

Things can be so easy...
Great!
Thomas.

stellkang said...

How can you get rid of the prompt dialog box and just directly print the pdf?

Palle Agermark said...

It seems like the Foxit Reader is able to print PDF much faster, via the command line, than Adobe Reader:

http://www.bincsoft.com/articles/background-printing-of-pdf-documents/