August 30, 2013

Print PDF files from AX X++ code

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

5 comments:

  1. Good day! This post couldn't be written any better!
    Reading this post reminds me of my good old
    room mate! He always kept chatting about this. I will forward this write-up to him.

    Pretty sure he will have a good read. Thanks for sharing!

    Also visit my weblog; rencontre femme cougar

    ReplyDelete
  2. This online pdf merger or pdf combiner or pdf joiner will easily merge pdf files together with use of any software or any registration. pdf merge

    ReplyDelete
  3. Waow this is quite pleasant article, my sister love to read such type of post, I am going to tell her and bookmarking this webpage. Thanks cheap post card printing

    ReplyDelete
  4. You can check this by the arranging, format, content and pictures in the changed over document. altocompresspdf.com

    ReplyDelete
  5. We are truly thankful for your blog entry. You will discover a great deal of methodologies in the wake of going to your post. I was precisely scanning for. A debt of gratitude is in order for such post and please keep it up.
    merge pdf online free

    ReplyDelete

Thanks

Note: Only a member of this blog may post a comment.