I'm trying to print a PDF file in PowerShell to another PDF (to remove some properties), using this earlier thread. It's essentially the same code I'm using, but I'm adding 'Microsoft Print to PDF' as the printer. It doesn't throw any errors, but it seems to just generate a blank pdf.
$PrintDocument = New-Object System.Drawing.Printing.PrintDocument
$PrintDocument.DocumentName = "c:\temp\fileToOpen.pdf"
$printDocument.PrinterSettings.PrintToFile = $true
$PrintDocument.PrinterSettings.PrinterName = "Microsoft Print to PDF"
$printDocument.PrinterSettings.PrintFileName = "c:\temp\newFile.pdf" #this is the blank file
$PrintDocument.Print()
Does anyone know what I'm doing wrong here? Thanks so much