利用powershell转wps文档到pdf

$input_path = "D:\wps"
$output_path = "D:\pdf"
$wps = New-Object -ComObject KWPS.Application

$Format = [Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatPDF

Get-ChildItem -Path $input_path -Filter *.doc? | ForEach-Object {
    $doc = $wps.Documents.Open($_.FullName)
    $pdf = "$output_path\$($_.BaseName).pdf"
    $doc.ExportAsFixedFormat([ref] $pdf, [ref] $Format)
    $doc.Close()
}
$wps.Quit()
posted @ 2024-07-07 00:26  卓能文  阅读(6)  评论(0编辑  收藏  举报