1

我正在尝试将 pdf 转换为 word 并通过 api 以编程方式保存它。我已经通过更改其他参考中的代码来尝试在 C# 示例文件夹中的 sdk 中给出的示例。但是我收到反射错误,因为“目标类型不匹配”。这是我的代码

AcroPDDoc pdfd = new AcroPDDoc();
pdfd.Open(filename);[enter image description here][1]
Object jsObj = pdfd.GetJSObject();
Type jsType = pdfd.GetType();
//have to use acrobat javascript api because, acrobat
 object[] saveAsParam = { "newFile.docx", "com.adobe.acrobat.docx", "", 
false, false };
jsType.InvokeMember("saveAs", BindingFlags.InvokeMethod | 
BindingFlags.Public | BindingFlags.Instance, null, jsObj, saveAsParam, 
CultureInfo.InvariantCulture);

将打开一个对话框并选择要转换的文件。据我所知,这是许多人的工作代码。我做错了什么。请帮忙。我的系统上安装了 Acrobat DC。这是我的版本

版本:Adobe Acrobat Pro DC 2017.009.20044

4

1 回答 1

-1

使用 C# 将 PDF 转换为 Word (.docx):

AcroPDDoc() pdfDoc = new AcroPDDoc();
if (pdfDoc.Open(sourceFileName))
{
    Object jsObj = pdfDoc.GetJSObject();
    Type type = jsObj.GetType();
    object[] saveAsParam = { convertedFilePath, "com.adobe.acrobat.docx" };
    type.InvokeMember(
        "saveAs",
        BindingFlags.InvokeMethod |
        BindingFlags.Public |
        BindingFlags.Instance,
        null, jsObj, saveAsParam);
}
于 2018-10-12T06:41:10.507 回答