powershell 如何自动填充pdf提示窗口中的字段以进行打印

0md85ypi  于 2023-02-04  发布在  Shell
关注(0)|答案(1)|浏览(117)

我想不使用软件包或LibreOffice将JPG转换为PDF。我使用PowerShell,我在这里找到了JPG到PDF与MS打印到PDF:https://community.spiceworks.com/topic/2233896-powershell-convert-jpg-to-pdf-using-pdf-printer,但当运行时,它显示窗口,我必须手动文件的全名。我想自动填充,但还没有找到一种方法。希望大家帮助我。
我用了passthru但是没有效果。还没有找到任何

3wabscal

3wabscal1#

如果你只是在寻找输入文件的路径,那么你可以在Get-childitem部分硬编码你的完整路径来改变它。改变文件路径到任何你想要的输入文件路径和文件名,你应该很好。我已经在同一行添加了一个注解供你参考。

$scandir="C:\IT Tools\Print to PDF Powershell\Test-JPG"$scanlogdir="C:\IT Tools\Print to PDF Powershell\Logs"
$pdftoprint=""
$printername= "Nitro PDF Creator (Pro 9)"

#Change the file name and file path of the jpg file # Cleanup old pdf files - Change AddDays value as required
Get-ChildItem "$scanbdir\*.jpg" | ? {LastWriteTime -LT (Get-Date).AddDays(-15)} | Remove-Item -Confirm:$false

# Create a Log file $scanlogname
$scanlogname = Join-Path -Path $scanlogdir -ChildPath "$(Get-Date -Format 'MM-dd-yyyy').log"

# Get the List of files in the Directory
echo "$(get-date) - Checking for any scanned pdf files in $scandir" | Out-File -Append $scanlogname

(Get-WmiObject -ComputerName localhost -Class Win32_Printer -Filter "Name='Nitro PDF Creator (Pro 9)'").setdefaultprinter()

Get-ChildItem -Path $scandir -filter "*.jpg" | % {

Start-Process -FilePath $_.VersionInfo.FileName –Verb print

#out-printer -InputObject $scandir\$pdftoprint $printername

"$(get-date) - Printing file - $_ on Printer - $printername" | Out-File -Append $scanlogname

}

相关问题