本帖最后由 terse 于 2023-10-7 12:53 编辑
如今含中文故保存文件编码为ANSI试
另外 这个要看你什么系统 还有就是要Microsoft Office支持- <# :
- @echo off
- powershell -noprofile -NoLogo "iex(${%~f0}|out-string)"
- pause
- exit
- #>
- $folderPath = 'E:\桌面\PDF'
- $folderName = Split-Path $folderPath -Leaf
- $word = New-Object -ComObject Word.Application
- $doc = $word.Documents.Add()
- Get-ChildItem -Path $folderPath\* -File -Include *.jpg,*.png | % {
- [void]$doc.InlineShapes.AddPicture($_.FullName)
- }
-
- $doc.SaveAs([Ref] "$folderPath\$folderName.pdf", [Ref] 17)
- $doc.Close([Ref] $false)
- $word.Quit()
- [Runtime.Interopservices.Marshal]::ReleaseComObject($word) | Out-Null
复制代码
|