环境:win7,64位,vs2008,Adobe Acrobat 9 Pro
代码:
1.新建一mfc对话框,在Ctest0915App::InitInstance()添加
CoInitialize(NULL);
在stdafx.h添加
#import "D:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\acrobat.tlb" auto_search,rename_namespace("Acrobat")
2.添加一按钮,代码如下
void Ctest0915Dlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
_bstr_t bstrFileName("E:\\1.pdf");
Acrobat::CAcroAppPtr acrapp;
CLSID clsid;
::CLSIDFromProgID(L"AcroExch.App", &clsid);
HRESULT hr = acrapp.CreateInstance(clsid);
Acrobat::CAcroAVDocPtr acrdoc;
acrdoc.CreateInstance(__uuidof(Acrobat::CAcroAVDoc));
hr = acrapp->Show();
hr = acrdoc->Open(bstrFileName, _bstr_t("1.pdf"));
acrdoc->BringToFront();
Acrobat::CAcroPDDocPtr acrpd= acrdoc->GetPDDoc();
int num = acrpd->GetNumPages();
acrapp->CloseAllDocs();
acrapp->Hide();
acrapp->Exit();
}
参考:
http://bbs.csdn.net/topics/240015528
http://bbs.csdn.net/topics/380235565
http://blog.sina.com.cn/s/blog_5922b64101011s3d.html
http://bbs.csdn.net/topics/70229569
ps:Adobe Acrobat是收费的,下一步要用adobe reader或国产开源pdf代替