Printing to PDF via script is printing blank documents RRS feed

  • Question

  • I am trying to use powershell to print each item (.tif files) in a directory as PDF's, while retaining their original file names. I would like this to happen with no user intervention. I am using Microsoft Print to PDF.  

    I found the following script which i was planning to modify for my scenario -

    function ConvertTo-PDF {

    Add-Type -AssemblyName System.Drawing
    $doc = New-Object System.Drawing.Printing.PrintDocument
    $doc.DocumentName = $TextDocumentPath
    $doc.PrinterSettings = new-Object System.Drawing.Printing.PrinterSettings
    $doc.PrinterSettings.PrinterName = 'Microsoft Print to PDF'
    $doc.PrinterSettings.PrintToFile = $true
    $pdf= [io.path]::Combine($file.DirectoryName, $file.BaseName) + '.pdf'
    $doc.PrinterSettings.PrintFileName = $pdf

    However when i do this, it outputs a blank pdf file with the correct name. Any ideas? 

    Tuesday, July 16, 2019 6:25 PM

All replies

  • You cannot print a TIFF as a text document. It must be printed with an imaging program.


    Tuesday, July 16, 2019 8:01 PM