Open PDF in AX 4

i want to open a pdf file in AX (Axapta 4). My first intension was something like the code below, but this is not realy a good way (because of the fix path…).

Is there a “standard” way to do this?

Thanks in advance,

int ShowPDF(str FilePathLocation)
System.Diagnostics.Process proc;
// 58925
new InteropPermission(InteropKind::ClrInterop).assert();
proc = System.Diagnostics.Process::Start(@‘C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe’,
// proc.WaitForExit();
return proc.get_ExitCode();

Simply use:


Windows will open the file in the program associated with the file type.

Some things are so easy… Thanks a lot :slight_smile:

Hi Martin,

Hope things are good at your end.

I need to open a .pdf file stored in shared drive from a web page in Enterprise Portal in AX 2012 R2.

I have designed a custom class that uses WinApi::ShellExecute to open .pdf file. This works fine on AX thick client.

Unfortunately, WinApi::ShellExecute doesn’t work if i access my X++ class from a web control. The page throws exception.

May be you would like to suggest an approach for this.

Thanks in advance!

Have a nice evening.

Best regards,


Hi again,

I tried below code and the .pdf file seems to open from EP in AX 2012 R2.

I created a new web control and added the web url menu item to the approval node. Hence on click of the approval records from Role center pages my web page gets called. Below is the code snippet to be written under page load:

protected void Page_Load(object sender, EventArgs e)


FileInfo fi = null;

String FileName;

AxTableContext tableContext = this.AxQueryString.RecordContext;

IAxaptaRecordAdapter tableRecordAdapter = tableContext.DataKey.GetRecord(this.AxSession);

FileName = tableRecordAdapter.Caption;

FileName = FileName.Replace(":",string.Empty);

string newFileName = string.Format(“C:/{0}.pdf”, FileName);

fi = new FileInfo(newFileName);

if (fi.Exists)



Response.ContentType = “application/pdf”;






Happy Coding!

Adoebe program will open pdf file for you. and there are many other .net imaging application has the same function to process and edit pdf document in an easy way. best luck

tag:open pdf/create pdf