将PDF文档转换为Word文档
bool ConvertToDocx(const wchar_t* pdf_path, const wchar_t* dest_path) {
    PDF2Word pdf_to_word;
    auto open_result = pdf_to_word.Open(pdf_path);
    if (open_result == PDF2Word::kOpenSuccess) {
        return pdf_to_word.Save(dest_path);
}
return false;
}
方法:PDF2Word::Open
方法说明:打开PDF文档
调用参数说明:
| 
 参数  | 
 类型  | 
 必须  | 
 说明  | 
| 
 file_path  | 
 const char*或 const wchar_t*  | 
 是  | 
 PDF文档路径。  | 
| 
 password  | 
 const unsigned char*  | 
 否  | 
 密码  | 
| 
 password_length  | 
 size_t  | 
 否  | 
 密码长度  | 
返回类型:
| 
 类型  | 
 说明  | 
| 
 /** * @brief 打开结果 */ enum OpenResult { kOpenFailed, kOpenSuccess, kOpenNeedPassword = 4, };  | 
 打开是否成功。  | 
PDF2Word pdf_to_word;
unsigned char pwd[100] = {  "123456" };
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf", pwd, 6u);
if (open_result != PDF2Word::kOpenSuccess) {
    switch (open_result) {
        case PDF2Word::kOpenFailed:
            std::cerr << "打开文档失败." << std::endl;
            break;
        case PDF2Word::kOpenNeedPassword:
            std::cerr << "文档需要密码." << std::endl;
        default:
            break;
    }
}
方法:PDF2Word::AddPageRange
方法说明:添加转换页面范围,默认转换全部页面
调用参数说明:
| 
 参数  | 
 类型  | 
 必须  | 
 说明  | 
| 
 start  | 
 unsigned int  | 
 是  | 
 起始页面  | 
| 
 end  | 
 unsigned int  | 
 是  | 
 结束页面  | 
| 
 step  | 
 unsigned int  | 
 否  | 
 步进,默认值是1  | 
返回类型:
| 
 类型  | 
 说明  | 
| 
 Void  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
    pdf_to_word.AddPageRange(2u,5u);
}
方法:PDF2Word::SetRegion
方法说明:设置转换页面矩形区域
调用参数说明:
| 
 参数  | 
 类型  | 
 必须  | 
 说明  | 
| 
 left  | 
 float  | 
 是  | 
 矩形区域左上角x轴坐标值  | 
| 
 top  | 
 float  | 
 是  | 
 矩形区域左上角y轴坐标值  | 
| 
 right  | 
 float  | 
 是  | 
 矩形区域右下角x轴坐标值  | 
| 
 bottom  | 
 float  | 
 是  | 
 矩形区域右下角y轴坐标值  | 
返回类型:
| 
 类型  | 
 说明  | 
| 
 Void  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
    pdf_to_word.SetRegion(100,300,200,200);
}
方法:PDF2Word::GetIgnoreImage
方法说明:获取忽略页面中的图片,默认为否
返回类型:
| 
 类型  | 
 说明  | 
| 
 Bool  | 
 是否忽略页面中的图片  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
pdf_to_word.SetIgnoreImage(true);
if (pdf_to_word.GetIgnoreImage()) {
    std::cout << "忽略图片." << std::endl;
}
}
方法:PDF2Word::GetImageOfEntirePage
方法说明:获取是否将每一页转换为一张图片,默认为否
返回类型:
| 
 类型  | 
 说明  | 
| 
 bool  | 
 是否将每一页转换为一张图片  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
pdf_to_word.SetImageOfEntirePage(true);
if (pdf_to_word.GetImageOfEntirePage()) {
    std::cout << "整个页面转换为图片." << std::endl;
}
}
方法:PDF2Word::GetImageDpi
方法说明:获取文档中图片的DPI
返回类型:
| 
 类型  | 
 说明  | 
| 
 float  | 
 DPI值  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
    std::cout <<“DPI:”<< pdf_to_word.GetImageDpi() << std::endl;
}
方法:PDF2Word::SetIgnoreImage
方法说明:设置忽略页面中的图片
调用参数说明:
| 
 参数  | 
 类型  | 
 必须  | 
 说明  | 
| 
 ignore_image  | 
 bool  | 
 是  | 
 忽略页面中的图片  | 
返回类型:
| 
 类型  | 
 说明  | 
| 
 Void  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
pdf_to_word.SetIgnoreImage(true);
}
方法:PDF2Word::SetImageOfEntirePage
方法说明:设置是否将每一页转换为一张图片
调用参数说明:
| 
 参数  | 
 类型  | 
 必须  | 
 说明  | 
| 
 image_of_entire_page  | 
 Bool  | 
 是  | 
 是否将每一页转换为一张图片  | 
返回类型:
| 
 类型  | 
 说明  | 
| 
 Void  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
pdf_to_word.SetImageOfEntirePage(true);
}
方法:PDF2Word::SetImageDpi
方法说明:设置转换后图片的DPI
调用参数说明:
| 
 参数  | 
 类型  | 
 必须  | 
 说明  | 
| 
 dpi  | 
 float  | 
 是  | 
 图片的DPI  | 
返回类型:
| 
 类型  | 
 说明  | 
| 
 Void  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
pdf_to_word.SetImageDpi(90);
}
方法:PDF2Word::GetIgnoreLink
方法说明:获取是否忽略页面中的超链接
返回类型:
| 
 类型  | 
 说明  | 
| 
 bool  | 
 是否忽略页面中的超链接  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
pdf_to_word.SetIgnoreLink(true);
if (pdf_to_word.GetIgnoreLink()) {
    std::cout << "忽略超链接." << std::endl;
}
}
方法:PDF2Word::SetIgnoreLink
方法说明:设置是否忽略页面中的超链接
调用参数说明:
| 
 参数  | 
 类型  | 
 必须  | 
 说明  | 
| 
 ignore_link  | 
 bool  | 
 是  | 
 是否忽略页面中的超链接  | 
返回类型:
| 
 类型  | 
 说明  | 
| 
 Void  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
pdf_to_word.SetIgnoreLink(true);
}
方法:PDF2Word::Save
方法说明:保存转换的文档
调用参数说明:
| 
 参数  | 
 类型  | 
 必须  | 
 说明  | 
| 
 dest_path  | 
 const char*或 const wchar_t*  | 
 是  | 
 目标文件路径  | 
| 
 office_version  | 
 /** * @brief Office版本 */ enum OfficeVersion { kOffice2003 = 0, kOffice2007 = 1 };  | 
 否  | 
 Office版本,默认为2007  | 
| 
 progress  | 
 Progress  | 
 否  | 
 保存进度通知对象,默认为空  | 
返回类型:
| 
 类型  | 
 说明  | 
| 
 Void  | 
PDF2Word pdf_to_word;
auto open_result = pdf_to_word.Open(L"F:\\source\\test.pdf");
if (open_result == PDF2Word::kOpenSuccess) {
pdf_to_word.SetIgnoreLink(true);
pdf_to_word.Save(L"F:\\output\\test.docx");
}