1

I have a C# windows forms application that displays the user a pdf. I use the axAcroPDF control like that:

AxAcroPDFLib.AxAcroPDF pdfViewer = new AxAcroPDFLib.AxAcroPDF();
...
pdfViewer.loadFile(@"C:\a.pdf");

This works fine on my PC and on my colleagues', but only on the ones who have win7 running. When trying on a winXp machine it does not work, i.e. loadFile() returns false.

Any ideas?

Cœur
  • 37,241
  • 25
  • 195
  • 267
nogola
  • 214
  • 4
  • 12

2 Answers2

0

Is AxAcroPDFLib supplied with Adobe Reader or other Adobe product, if so I guess you would need that installed on the target machine, checking that the versions are compatible?

and.. can see the same PDF in the same location (if thats not example code)

Mark Redman
  • 24,079
  • 20
  • 92
  • 147
  • In my opinion, the application would generate an exception if the AX control is not available on the target machine. It could only be that they're not compatible. But how do I create an app that displays pdf's on any machine that has installed Adobe Reader...?? – nogola Apr 06 '11 at 07:49
  • I guess you would need to create the .Net wrapper for each version of the control and detect which one it is? Or have users install a specific version. Another option might be to open PDF's using a browser on the users machine rather than within your application to get around any issues? – Mark Redman Apr 06 '11 at 08:31
  • I'm trying the solution with the browser. But on the machine with XP it says that security settings do not allow file downloads, when assigning the Url of the webBrowser control to a pdf's file location... – nogola Apr 06 '11 at 08:38
0

Ok, I solved it by late binding the reader by implementing axHost like this:

public class LateBoundPDFReader : AxHost
{
    public LateBoundPDFReader()
        : base("{CA8A9780-280D-11CF-A24D-444553540000}")
    {
    }
}

The only thing is, now I cannot use it in the designer of VS...why...?

nogola
  • 214
  • 4
  • 12