1

I am trying to convert TIF files into PDF Files. Below is the code that does the conversion however, when it converts i loose the content in the TIF files and only get blank PDF files. How do I convert the files and keep the picture on the original TIF file.

$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

}
4

2 回答 2

0

As @Preet Sangha has said, you need to double quote the parameters.

This should do it:

$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')
}

EDIT: Changed to use Start-Process instead of &

于 2013-07-08T12:27:55.537 回答
0

根据命令行参考,您需要在文件名和输出格式周围加上双引号。

例如

pdfcreator.exe /IF"C:\description.ps" /OF"C:\description.pdf" /OutputSubFormat"PDF/A-1b"
于 2013-07-08T12:17:35.183 回答