How to open pdf files from Ax using X++ in Ax 2012

static void Johnkrish_OpenPdfFileInAx(Args _args)
Filename pdfFileName = ‘123.pdf’;
FilePath pdfFilePath = @’E:’;
str adobeExe;

System.Diagnostics.Process process;
System.Diagnostics.ProcessStartInfo processStartInfo;

// Let Windows figure out the standard program and location for the PDF reader
adobeExe = WinAPI::findExecutable(pdfFilePath + pdfFileName);

// Start the reader process
new InteropPermission(InteropKind::ClrInterop).assert();

process = new System.Diagnostics.Process();

processStartInfo = new System.Diagnostics.ProcessStartInfo();
processStartInfo.set_Arguments(pdfFilePath + pdfFileName);



// Wait 5 secs. before closing the window
//sleep (5000);

// Close the window


3 comments on “How to open pdf files from Ax using X++ in Ax 2012

  1. Yes, its very helpful to open pdf file. but note: i do not want many options which is available in PDF view. e.g. Print, Save As etc. my main objective is, this document is for reading purpose, user must not be able to take action (print, export, save as, web etc).


  2. Hi Ramzan,

    That is because of your PDF viewer like Adobe, etc.. Just we are trying to open the pdf file, not only pdf any type of file can be open by this code.The code will open the application for that file extension with the given file.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s