Permitir script de execução no powershell, digite em cmd
run como administrador:
Selecione o pino cmd
pressione Shift + Clique com o botão direito do mouse
powershell -command "Set-ExecutionPolicy RemoteSigned"
CrieumapastaPdfConvertnaáreadetrabalho,executePdf2Docx4.cmd
Converta todo o arquivo pdf na pasta $ PDFpath :) para docx.
Pdf2Docx4.cmd:
powershell .\PdfConvert\Pdf2Docx4.ps1
Pdf2Docx4.ps1:
$TypeExt="docx"
$closeDocParam = $true;
$PDFpath = "D:\VBS\PS-29-AcrobatProX\"
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;
}