Link to home
Start Free TrialLog in
Avatar of Olav00007
Olav00007

asked on

How do I add an Adobe Acrobat Reader control to a VB.NET Windows Forms user control programatically?

AxAcroPDFLib.AxAcroPDF, VB.NET 2005.
My main problem is the OcxState
C# welcome

For immediate answer
Avatar of VBRocks
VBRocks
Flag of United States of America image

Just add a WebBrowser control to your form, then use the Navigate() method to navigate to the .pdf.  Adobe Acrobat Reader will open automatically.

ASKER CERTIFIED SOLUTION
Avatar of VBRocks
VBRocks
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Olav00007
Olav00007

ASKER

Very interesting solutions.  Can you control buttons and bars this way?
Right now my approach is to drip the OCX in a Custom control, and manipulate those, but I can figure out how to remove bars and buttons.

Create your own custom controls and handle it programmatically.

The webcontrol solution was developed in another thread:
https://www.experts-exchange.com/questions/23702092/Pdf-in-VB-NET-Windows-Forms-without-buttons-and-toolbars-AxAcroPDF-OCX-control.html?cid=748&anchorAnswerId=22399231#a22399231

I will continue with a "ask a related question".

I suggest using this thread for non-webcontrol solutions.


Avatar of Bob Learned
1) What version of Acrobat Reader do you have?

2) How did you attempt to programmatically add a control, and what are all problems that you had?
     Public AcroExchPDDoc() As Acrobat.CAcroPDDoc
..........

     AcroExchPDDoc(fIndex) = CreateObject("AcroExch.PDDoc")
Cannot create ActiveX component.

This is the StaticViewVB example from the Adobe STK
(I dont know so much about ActiveX and automation - might be simple)


Also I have tried a drag-drop to a user-control.  That gives the object  AxAcroPDF
which doesn't seem to be powerful enough (removing buttons etc.)

Have Adobe Reader 8 and 9




Are you able to drop an Acrobat Reader control on a form?
>Are you able to drop an Acrobat Reader control on a form?
Yes thats what I am discussing here:
Also I have tried a drag-drop to a user-control.  That gives the object  AxAcroPDF
which doesn't seem to be powerful enough (removing buttons etc.)
It is supposed to work with Acrobat Reader.  

And it seems like the class Acrobat.CAcroPDDoc from aboveis only for Standard/Professional.
Have you tried to remove toolbars like this of AxAcroPDFLib.AxAcroPDF

Me.AxPDF.setShowScrollbars(False)
Me.AxPDF.setShowToolbar(False)
I have been checking it out for a while the two toolbar commands work, but there are still icons on the left, and pages are under eachother, not one by one.
Also getting file-name, number of pages, getting and setting current page number...
(Found how to set pagenumber) In addition I have the message:The maximum number of PDF documents that can be simultaneous opened in the browser has been exceeded
I dug through some code that I keep in my back pocket, and I came up with this class that I designed for a project that I had about 2-3 years ago to work with Acrobat:


using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Text;
 
public class AcrobatServices : IDisposable
{
 
    private CAcroPDDoc _Document = null;
    private CAcroPDPage _CurrentPage = null;
    private int _pageNumber = 0;
    private string _currentFileName = "";
 
    public AcrobatServices()
    {
    }
 
    public AcrobatServices(string fileName)
    {
        this.OpenPDFDocument(fileName);
    }
 
    public void OpenPDFDocument(string fileName)
    {
        if (!File.Exists(fileName))
            throw new FileNotFoundException();
 
        _Document = (CAcroPDDoc)Activator.CreateInstance(Type.GetTypeFromProgID("AcroExch.PDDoc"));
        _Document.Open(fileName);
 
        _currentFileName = fileName;
    }
 
    public Image DrawToBitmap(int zoomLevel, int pageNumber, IntPtr handle)
    {
        return DrawToBitmap(-1, -1, zoomLevel, pageNumber, handle);
    }
 
    public Image DrawToBitmap(int width, int height, int zoomLevel, int pageNumber, IntPtr handle)
    {
        if (pageNumber < 0 || pageNumber >= this.PageCount)
            throw new ArgumentOutOfRangeException("Page number");
 
        _pageNumber = pageNumber;
 
        _CurrentPage = (CAcroPDPage)_Document.AcquirePage(_pageNumber);
 
        if (_CurrentPage == null)
            throw new ArgumentNullException("Current page");
 
        CAcroPoint point = (CAcroPoint)_CurrentPage.GetSize();
        CAcroRect rect = (CAcroRect)Activator.CreateInstance(Type.GetTypeFromProgID("AcroExch.Rect"));
 
        width = Math.Max(width, point.x);
        height = Math.Max(height, point.y);
 
        rect.Left = 0;
        rect.Top = 0;
        rect.right = (short)width;
        rect.bottom = (short)height;
 
        using (ClipboardHelper helper = new ClipboardHelper())
        {
            _CurrentPage.CopyToClipboard(rect, 0, 0, (short)zoomLevel);
            Image image = helper.GetImage();
            return image;
        }
 
    }
 
    public string FileName
    {
        get { return _currentFileName; }
    }
 
    public int PageCount
    {
        get
        {
            if (_Document == null)
                throw new ArgumentNullException("Document");
 
            return _Document.GetNumPages();
        }
    }
 
    public int PageNumber
    {
        get { return _pageNumber; }
    }
 
    public void Dispose()
    {
        this.CloseDocument();
    }
 
    public void CloseDocument()
    {
        if (_Document != null)
            _Document.Close();
 
        _Document = null;
    }
 
 
    #region Interfaces
    [ComImport, Guid("9B4CD3E7-4981-101B-9CA8-9240CE2738AE"), TypeLibType((short)0x1000), InterfaceType((short)2)]
    private interface CAcroPDDoc
    {
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)]
        int Open([MarshalAs(UnmanagedType.BStr)] string szFullPath);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
        int Close();
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
        int InsertPages(int nInsertPageAfter, [MarshalAs(UnmanagedType.IDispatch)] object iPDDocSource, int nStartPage, int nNumPages, int bBookmarks);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
        int ReplacePages(int nStartPage, [MarshalAs(UnmanagedType.IDispatch)] object iPDDocSource, int nStartSourcePage, int nNumPages, int bMergeTextAnnotations);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
        int DeletePages(int nStartPage, int nEndPage);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)]
        int GetNumPages();
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)]
        int Create();
        [return: MarshalAs(UnmanagedType.BStr)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)]
        string GetInfo([MarshalAs(UnmanagedType.BStr)] string szInfoKey);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)]
        int SetInfo([MarshalAs(UnmanagedType.BStr)] string szInfoKey, [MarshalAs(UnmanagedType.BStr)] string szBuffer);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)]
        int DeleteThumbs(int nStartPage, int nEndPage);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)]
        int MovePage(int nMoveAfterThisPage, int nPageToMove);
        [return: MarshalAs(UnmanagedType.BStr)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)]
        string GetFileName();
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)]
        int GetPageMode();
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)]
        int SetPageMode(int nPageMode);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)]
        int CreateThumbs(int nFirstPage, int nLastPage);
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)]
        object CreateTextSelect(int nPage, [MarshalAs(UnmanagedType.IDispatch)] object iAcroRect);
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)]
        object AcquirePage(int nPage);
        [return: MarshalAs(UnmanagedType.BStr)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x12)]
        string GetInstanceID();
        [return: MarshalAs(UnmanagedType.BStr)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x13)]
        string GetPermanentID();
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(20)]
        int GetFlags();
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x15)]
        int SetFlags(int nFlags);
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x16)]
        object OpenAVDoc([MarshalAs(UnmanagedType.BStr)] string szTempTitle);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x17)]
        int Save(short nType, [MarshalAs(UnmanagedType.BStr)] string szFullPath);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x18)]
        int ClearFlags(int nFlags);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x19)]
        int SetOpenInfo(int pgNum, short viewMode, [MarshalAs(UnmanagedType.BStr)] string magnification);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1a)]
        int CropPages(int nStartPage, int nEndPage, short nOddOrEvenPagesOnly, [MarshalAs(UnmanagedType.IDispatch)] object iAcroRect);
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x1b)]
        object GetJSObject();
    }
 
    [ComImport, TypeLibType((short)0x1000), InterfaceType((short)2), Guid("9B4CD3EA-4981-101B-9CA8-9240CE2738AE")]
    private interface CAcroPDPage
    {
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)]
        object GetSize();
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)]
        object GetAnnot(int nIndex);
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)]
        object AddNewAnnot(int nIndexAddAfter, [MarshalAs(UnmanagedType.BStr)] string szSubType, [MarshalAs(UnmanagedType.IDispatch)] object rect);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)]
        int AddAnnot(int nIndexAddAfter, [MarshalAs(UnmanagedType.IDispatch)] object i);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(5)]
        int RemoveAnnot(int nIndex);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(6)]
        int GetAnnotIndex([MarshalAs(UnmanagedType.IDispatch)] object i);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(7)]
        int GetNumAnnots();
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(8)]
        object CreatePageHilite([MarshalAs(UnmanagedType.IDispatch)] object iAcroHiliteList);
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(9)]
        object CreateWordHilite([MarshalAs(UnmanagedType.IDispatch)] object iAcroHiliteList);
        [return: MarshalAs(UnmanagedType.IDispatch)]
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(10)]
        object GetDoc();
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(11)]
        int GetNumber();
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(12)]
        int Draw(short nHWND, short nHDC, short nXOrigin, short nYOrigin, short nZoom);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(13)]
        short GetRotate();
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(14)]
        int SetRotate(short nRotate);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(15)]
        int DrawEx(int nHWND, int nHDC, [MarshalAs(UnmanagedType.IDispatch)] object updateRect, short nXOrigin, short nYOrigin, short nZoom);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x10)]
        int CopyToClipboard([MarshalAs(UnmanagedType.IDispatch)] object boundRect, short nXOrigin, short nYOrigin, short nZoom);
        [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(0x11)]
        int CropPage([MarshalAs(UnmanagedType.IDispatch)] object rect);
    }
 
    [ComImport, InterfaceType((short)2), Guid("9B4CD3EC-4981-101B-9CA8-9240CE2738AE"), TypeLibType((short)0x1000)]
    private interface CAcroPoint
    {
        [DispId(1)]
        short x { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
        [DispId(2)]
        short y { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
    }
 
    [ComImport, InterfaceType((short)2), Guid("9B4CD3ED-4981-101B-9CA8-9240CE2738AE"), TypeLibType((short)0x1000)]
    private interface CAcroRect
    {
        [DispId(1)]
        short Left { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] get; [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)] set; }
        [DispId(2)]
        short Top { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] get; [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2)] set; }
        [DispId(3)]
        short right { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] get; [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(3)] set; }
        [DispId(4)]
        short bottom { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] get; [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(4)] set; }
    }
 
    #endregion
 
}
 
public class ClipboardHelper : IDisposable
{
 
    private enum DataFormat
    {
        CF_TEXT = 0x1,
        CF_BITMAP = 0x2,
        CF_METAFILEPICT = 0x3,
        CF_SYLK = 0x4,
        CF_DIF = 0x5,
        CF_TIFF = 0x6,
        CF_OEMTEXT = 0x7,
        CF_DIB = 0x8,
        CF_PALETTE = 0x9,
        CF_PENDATA = 0xA,
        CF_RIFF = 0xB,
        CF_WAVE = 0xC,
        CF_UNICODETEXT = 0xD,
        CF_ENHMETAFILE = 0xE,
        CF_HDROP = 0xF,
        CF_LOCALE = 0x10,
        CF_MAX = 0x11,
        CF_OWNERDISPLAY = 0x80,
        CF_DSPTEXT = 0x81,
        CF_DSPBITMAP = 0x82,
        CF_DSPMETAFILEPICT = 0x83,
        CF_DSPENHMETAFILE = 0x8E,
        CF_PRIVATEFIRST = 0x200,
        CF_PRIVATELAST = 0x2FF,
        CF_GDIOBJFIRST = 0x300,
        CF_GDIOBJLAST = 0x3FF,
        CF_FILENAME = 0xC006,
        CF_FILENAMEW = 0xC007,
        CF_DATAOBJECT = 0xC009,
        CF_OLEPRIVATEDATA = 0xC013,
        CF_SHELLIDLIST = 0xC048,
        CF_HIDDENTEXTBANNERFORMAT = 0xC070,
        CF_RICHTEXTFORMAT = 0xC087,
        CF_SHELLOBJECTOFFSETS = 0xC099,
        CF_PREFERREDDROPEFFECT = 0xC0A2,
    }
 
    private Stack<DataClip> _Stack = null;
 
    public ClipboardHelper()
    {
        this.PushClipboard();
    }
 
    public void Dispose()
    {
        this.PopClipboard();
    }
 
    public void Empty()
    {
        Win32.EmptyClipboard();
    }
 
    /// <summary>
    /// Empty the Clipboard and Restore to system clipboard data contained in a collection of ClipData objects
    /// </summary>
    /// <param name="clipData">The collection of ClipData containing data stored from clipboard</param>
    /// <returns></returns>    
    private void PopClipboard()
    {
        if (!Win32.OpenClipboard(IntPtr.Zero))
            throw new ApplicationException("Cannot open clipboard");
 
        //Open clipboard to allow its manipultaion
        //Clear the clipboard
        Win32.EmptyClipboard();
 
        while (_Stack.Count > 0)
        {
            this.SetData(_Stack.Pop());
        }
 
        //Close the clipboard and release unused resources
        Win32.CloseClipboard();
    }
 
    public Image GetImage()
    {
        Dictionary<DataFormat, DataClip> data = this.GetClipboardData();
 
        if (data.ContainsKey(DataFormat.CF_BITMAP))
        {
            DataClip clip = data[DataFormat.CF_BITMAP];
            Image image = Image.FromHbitmap(clip.Handle);
            return image;
        }
        return null;
    }
 
    private void SetData(DataClip clip)
    {
        //Get the pointer for inserting the buffer data into the clipboard
        IntPtr alloc = Win32.GlobalAlloc(Win32.GMEM_MOVEABLE | Win32.GMEM_DDESHARE, clip.Size);
        IntPtr gLock = Win32.GlobalLock(alloc);
 
        //Clopy the buffer of the ClipData into the clipboard
        if ((int)clip.Size > 0)
            Marshal.Copy(clip.Buffer, 0, gLock, clip.Buffer.GetLength(0));
 
        //Release pointers 
        Win32.GlobalUnlock(alloc);
        Win32.SetClipboardData(clip.Format, alloc);
    }
 
    private void PushClipboard()
    {
        //Init a list of ClipData, which will contain each Clipboard Data
        _Stack = new Stack<DataClip>();
 
        Dictionary<DataFormat, DataClip> data = this.GetClipboardData();
 
        foreach (DataClip clip in data.Values)
            _Stack.Push(clip);
    }
 
    private Dictionary<DataFormat, DataClip> GetClipboardData()
    {
        // Loop for each clipboard data type
        uint format = 0;
 
        if (!Win32.OpenClipboard(IntPtr.Zero))
            throw new ApplicationException("Cannot open clipboard");
 
        Dictionary<DataFormat, DataClip> list = new Dictionary<DataFormat, DataClip>();
 
        while ((format = Win32.EnumClipboardFormats(format)) != 0)
        {
            //Check if clipboard data type is recognized, and get its name
            string formatName = "0";
 
            StringBuilder res = new StringBuilder();
 
            DataFormat dataFormat = (DataFormat)format;
 
            Win32.GetClipboardFormatName(format, res, 100);
            formatName = res.ToString();
 
            // Get the pointer for the current Clipboard Data 
            IntPtr pos = Win32.GetClipboardData(format);
 
            // Goto next if it's unreachable
            if (pos == IntPtr.Zero)
                continue;
 
            //Get the clipboard buffer data properties
            UIntPtr length = Win32.GlobalSize(pos);
            IntPtr gLock = Win32.GlobalLock(pos);
            byte[] buffer;
 
            //Init a buffer which will contain the clipboard data
            buffer = new byte[0];
 
            if ((int)length > 0 && dataFormat != DataFormat.CF_BITMAP)
            {
                buffer = new byte[(int)length];
                //Copy data from clipboard to our byte[] buffer
                Marshal.Copy(gLock, buffer, 0, (int)length.ToUInt32());
            }
 
            //Create a ClipData object that represtens current clipboard data
            DataClip clip = new DataClip(format, formatName, buffer, pos);
 
            list.Add(dataFormat, clip);
 
            Win32.GlobalUnlock(pos);
        }
 
        //Close the clipboard and release unused resources
        Win32.CloseClipboard();
 
        return list;
    }
 
    private class Win32
    {
        [DllImport("user32.dll")]
        public static extern bool OpenClipboard(IntPtr hWndNewOwner);
 
        [DllImport("user32.dll")]
        public static extern bool EmptyClipboard();
 
        [DllImport("user32.dll")]
        public static extern IntPtr GetClipboardData(uint uFormat);
 
        [DllImport("user32.dll")]
        public static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem);
 
        [DllImport("user32.dll")]
        public static extern bool CloseClipboard();
 
        [DllImport("user32.dll")]
        public static extern uint EnumClipboardFormats(uint format);
 
        [DllImport("user32.dll")]
        public static extern int GetClipboardFormatName(uint format, [Out] StringBuilder lpszFormatName, int cchMaxCount);
 
        [DllImport("user32.dll", SetLastError = true)]
        public static extern uint RegisterClipboardFormat(string lpszFormat);
 
        [DllImport("kernel32.dll")]
        public static extern IntPtr GlobalAlloc(uint uFlags, UIntPtr dwBytes);
 
        [DllImport("kernel32.dll")]
        public static extern IntPtr GlobalLock(IntPtr hMem);
 
        [DllImport("kernel32.dll")]
        public static extern IntPtr GlobalUnlock(IntPtr hMem);
 
        [DllImport("kernel32.dll")]
        public static extern IntPtr GlobalFree(IntPtr hMem);
 
        [DllImport("kernel32.dll")]
        public static extern UIntPtr GlobalSize(IntPtr hMem);
 
        public const uint GMEM_DDESHARE = 0x2000;
        public const uint GMEM_MOVEABLE = 0x2;
    }
 
    /// <summary>
    /// Holds clipboard data of a single data format.
    /// </summary>
    [Serializable]
    private class DataClip
    {
 
        public DataClip(uint format, string formatName, byte[] buffer, IntPtr handle)
        {
            this.format = format;
            this.formatName = formatName;
            this.buffer = buffer;
            this.size = 0;
            this.handle = handle;
        }
 
        private uint format;
 
        /// <summary>
        /// Get or Set the format code of the data 
        /// </summary>
        public uint Format
        {
            get { return format; }
        }
 
        private string formatName;
        /// <summary>
        /// Get or Set the format name of the data 
        /// </summary>
        public string FormatName
        {
            get { return formatName; }
        }
 
        private byte[] buffer;
 
        /// <summary>
        /// Get or Set the buffer data
        /// </summary>
        public byte[] Buffer
        {
            get { return buffer; }
        }
 
        private IntPtr handle = IntPtr.Zero;
 
        public IntPtr Handle
        {
            get { return handle; }
        }
 
        private int size;
 
        /// <summary>
        /// Get the data buffer length
        /// </summary>
        public UIntPtr Size
        {
            get
            {
                if (buffer != null)
                {
                    //Read the correct size from buffer, if it is not null
                    return new UIntPtr(Convert.ToUInt32(buffer.GetLength(0)));
                }
                else
                {
                    //else return the optional set size
                    return new UIntPtr(Convert.ToUInt32(size));
                }
            }
        }
    }
}

Open in new window

Isnt this for Standard/Professional, not Reader
I can't remember if there was Professional installed, or if this was for Acrobat Reader.  Did it not work for you?
It crashed on
_Document = (CAcroPDDoc)Activator.CreateInstance(Type.GetTypeFromProgID("AcroExch.PDDoc"));
Same as above ( ID: 22411312)

What Acrobat Reader version are you using?  I am using Version 9, and that code works fine, and I don't have Acrobat Professional installed.
I have reader 8 and 9.  Anyway, if I google AcroExch.PDDoc I get many links like this:
http://www.adobeforums.com/webx/.3c0551ea
1) I just started a new job, and I have a machine that was generated from an image.

2) I looked in Program Files, and found Acrobat 5.0 Professional

3) There was no indication that this application was installed, so I didn't know that it existed.

4) Now I have something concrete to understand that what you were saying was correct.

5) Sorry I couldn't help you.
I didn't go this way in the end, but it is certainly a way to do it.