2010-08-05 176 views
2

感謝你所有給出的答案... 在這裏我想問一個問題:將PDF轉換成Word文檔

什麼是PDF文件轉換爲Word文檔的最佳途徑。淨?

+0

你的問題是首先要求,但由於某種原因尚未收到許多答案。在這裏看到一個類似的問題:http://stackoverflow.com/questions/3687970/convert-pdf-to-anything-which-can-be-opened-byword – 2010-11-11 09:35:01

回答

1

將運行文件夾中的所有pdf保存爲docx。

將powershell腳本轉換爲C#。

在AcrobatX Pro中測試。

Pdf2Docx.ps1:

$TypeExt="docx" 
$closeDocParam = $true; 

Get-ChildItem -Filter *.pdf |Where { 

# logical document 

    $AVDoc = New-Object -ComObject AcroExch.AVDoc;  

    $AVDoc.Open($_.Fullname, "") | Out-Null; 
# physical document 

    $PDDoc = $AVDoc.GetPDDoc();       
    $JavaScriptObject = $PDDoc.GetJSObject();       
# get the bridge JavaScript Object 

    $T = $JavaScriptObject.GetType(); 

    $T.InvokeMember("SaveAs", 

     [Reflection.BindingFlags]::InvokeMethod -bor ` 
      [Reflection.BindingFlags]::Public  -bor ` 
      [Reflection.BindingFlags]::Instance   , 

     $null, 
     $JavaScriptObject, 
     @([IO.Path]::ChangeExtension($_.Fullname, $TypeExt), ("com.adobe.acrobat."+$TypeExt))); 

     $T.InvokeMember("closeDoc", 

     [Reflection.BindingFlags]::InvokeMethod -bor ` 
      [Reflection.BindingFlags]::Public  -bor ` 
      [Reflection.BindingFlags]::Instance   , 

      $null, 
      $JavaScriptObject, 
      $closeDocParam) | Out-Null; 

    $PDDoc.Close() | Out-Null; 
    $AVDoc.Close(1) | Out-Null; 
}