我正在尝试将TIF文件转换为PDF文件。下面是执行转换的代码,但是,当它转换时,我失去了TIF文件中的内容,只得到空白的PDF文件。如何转换文件并将图片保留在原始TIF文件中。
$InputLocation = "C:\convert"
$tool = 'C:Program Files (x86)\PDFCreator\PDFCreator.exe'
$tiffs = get-childitem -filter *.tif -path $InputLocation
foreach($tiff in $tiffs)
{
$filename = $tiff.FullName
$pdf = $tiff.FullName.split('.')[0] + '.pdf'
'Processing ' + $filename + ' to ' + $pdf
$param = "-sOutputFile=$pdf"
& $tool /IF$filename /OF$pdf /NoPSCheck /NoStart
}发布于 2013-07-08 20:27:56
正如@Preet Sangha所说,你需要用双引号引用参数。
这应该可以做到:
$InputLocation = "C:\convert"
$tool = 'C:Program Files (x86)\PDFCreator\PDFCreator.exe'
$tiffs = get-childitem -filter *.tif -path $InputLocation
foreach($tiff in $tiffs)
{
$filename = $tiff.FullName
$pdf = $tiff.FullName.split('.')[0] + '.pdf'
'Processing ' + $filename + ' to ' + $pdf
$param = "-sOutputFile=$pdf"
Start-Process $tool -ArgumentList ('/IF"' + $filename + '" /OF"' + $pdf + '/NoPSCheck /NoStart')
}启动编辑:已更改为使用-Process而不是&
发布于 2013-07-08 20:17:35
根据command line reference,您需要用双引号将文件名和输出格式括起来。
例如:
pdfcreator.exe /IF"C:\description.ps" /OF"C:\description.pdf" /OutputSubFormat"PDF/A-1b"https://stackoverflow.com/questions/17526281
复制相似问题