When I try to instantiate a PDF browser control like this in C#:
AcroPDFLib.AcroPDFClass acrobat = new AcroPDFLib.AcroPDFClass();
I get a COMException with this message:
Creating an instance of the COM component with CLSID {CA8A9780-280D-11CF-A24D-444553540000} from the IClassFactory failed due to the following error: 80004005.
I have made a reference to AcroPDF.dll which has the component name Adobe Acrobat 7.0 Browser Control Type Library 1.0.
When I run Visual C# 2008 Express Edition as administrator I get another error message:
Unable to cast COM object of type ‘AcroPDFLib.AcroPDFClass’ to interface type ‘AcroPDFLib.IAcroAXDocShim’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{3B813CE7-7C10-4F84-AD06-9DF76D97A9AA}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
This happens at the next line when I try to use the object:
acrobat.LoadFile("book.pdf");
I can’t figure out what is wrong. Help most appreciated!
These are the steps to use the Adobe PDF Reader control:
I’m not sure why but I have to run Microsoft Visual C# 2008 Express Edition with administrative privileges to get this working. With a limited user I get this message in the designer:
Note that after adding the Adobe PDF Reader control to your toolbox a new .NET interop assembly has been created with the name AxInterop.AcroPDFLib.dll. A reference to this new assembly has been added to your project references.
API reference documentation for the Adobe PDF Reader control is located here: http://icio.us/ajukkr
This forum thread provides some more useful information: http://forums.adobe.com/thread/438362