Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $path = "."
- # Convert all the ppt/pptx to PDF
- $powerpoint_app = New-Object -ComObject PowerPoint.Application
- # $powerpoint_app.Visible = [Microsoft.Office.Core.MsoTriState]::msoFalse
- # Search for files and convert
- Get-ChildItem -Path $path -Filter *.ppt? | ForEach-Object {
- # $ppSlideSizeOpt = [Microsoft.Office.Interop.PowerPoint.PpSlideSizeType]::ppSlideSizeOnScreen16x9
- # Open the presentation
- echo "# Opening the '$($_.BaseName)'..."
- $presentation = $powerpoint_app.Presentations.Open($_.FullName)
- $pdf_filename = "$($_.DirectoryName)\$($_.BaseName).pdf"
- # Resize the slide size to 16x9 if it's not yet
- if ($presentation.PageSetup.SlideWidth -ne 960)
- {
- $presentation.PageSetup.SlideWidth = 960
- $presentation.PageSetup.SlideHeight = 540
- $presentation.Save()
- echo "- Set the slide size to WideScreen. Saved it."
- } else
- {
- echo "- The slide size WAS WideScreen."
- }
- # Save as a PDF
- echo "- Saving as PDF ..."
- $opt = [Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType]::ppSaveAsPDF
- $presentation.SaveAs($pdf_filename, $opt)
- # Close the presentation object
- $presentation.Close()
- echo "- Saved as the '$($_.BaseName).pdf'"
- }
- sleep 3
- # Quit the app and release the app object
- $powerpoint_app.Quit()
- Stop-Process -name "POWERPNT"
- [System.Runtime.Interopservices.Marshal]::ReleaseComObject($powerpoint_app)
Add Comment
Please, Sign In to add comment