Convert pdf to Word document [closed]
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this questionThanks for the answers that you all given... Here I would like to ask one more question :
What is the best way to convert PDF document to Word document in .net?
Save all pdf in run folder to docx.
Convert powershell script to C#.
Test in 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;
}
精彩评论